Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds conditional formatting component #1843

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ctauchen
Copy link
Collaborator

@ctauchen ctauchen commented Jan 16, 2025

  • Adds a component that lets you add conditional formatting in MDX files.
  • POC for using shared _system-requirements.mdx file for different system requirements pages.

This functionality was previously done with full JSX code. The idea here is to allow us to do conditional formatting without having to hand-code everything in JSX.

Product Version(s):

Issue:

Link to docs preview:

https://deploy-preview-1843--tigera.netlify.app/calico/latest/getting-started/kubernetes/requirements
https://deploy-preview-1843--tigera.netlify.app/calico/latest/getting-started/openstack/requirements

SME review:

  • An SME has approved this change.

DOCS review:

  • A member of the docs team has approved this change.

Additional information:

Merge checklist:

  • Deploy preview inspected wherever changes were made
  • Build completed successfully
  • Test have passed

@ctauchen ctauchen requested a review from a team as a code owner January 16, 2025 15:49
Copy link

netlify bot commented Jan 16, 2025

Deploy Preview succeeded!

Built without sensitive environment variables

Name Link
🔨 Latest commit c23f3e8
🔍 Latest deploy log https://app.netlify.com/sites/tigera/deploys/678a4ed143a3fe0008eec887
😎 Deploy Preview https://deploy-preview-1843--tigera.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 26 (🟢 up 1 from production)
Accessibility: 90 (no change from production)
Best Practices: 83 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for calico-docs-preview-next ready!

Name Link
🔨 Latest commit c23f3e8
🔍 Latest deploy log https://app.netlify.com/sites/calico-docs-preview-next/deploys/678a4ed13c3578000883e616
😎 Deploy Preview https://deploy-preview-1843--calico-docs-preview-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ctauchen ctauchen force-pushed the docs-2434-conditional branch from 578b7b8 to 0418319 Compare January 16, 2025 15:51
@ctauchen
Copy link
Collaborator Author

@ronanc-tigera Here's the component in action. Anything I should be doing differently here before I proceed?

@ctauchen
Copy link
Collaborator Author

FYI @doucol A first docs-related thing we can do with the D3 upgrade.

- The range from which host IPs are allocated
</If>

<If condition = {props.platform === 'openstack'}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

props need to be formatted

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what formatting. What needs to be changed here?

@@ -0,0 +1,152 @@
import If from "/src/___new___/components/If";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should fix the import @site/src/___new___/components/If

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

import ReqsSys from '@site/calico_versioned_docs/version-3.29/_includes/components/ReqsSys';
import ReqsKernel from '@site/calico_versioned_docs/version-3.29/_includes/components/ReqsKernel';
import SystemRequirements from '../_system-requirements.mdx';
export const platform='host';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if 'host' is only used once, just put it directly in the props, no need for the variable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the concision. But for now I like the idea that I can define this (and other) attributes at the top of the doc, and leave everything that follows the same. I may go back on this later, but I've got a few ideas for things I plan to do where this will be a helpful paradigm.

---

# System requirements
import SystemRequirements from '../_system-requirements.mdx';
export const platform='kubernetes';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here

import ReqsSys from '@site/calico_versioned_docs/version-3.29/_includes/components/ReqsSys';
import ReqsKernel from '@site/calico_versioned_docs/version-3.29/_includes/components/ReqsKernel';
import SystemRequirements from '../_system-requirements.mdx';
export const platform='openstack';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -0,0 +1,7 @@
import React from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you typescriptify this?

import React from 'react';

type IfProps = {
    condition: boolean;
};

const If: React.FC<React.PropsWithChildren<IfProps>> = ({
    condition,
    children,
}) => {
    return condition ? <>{children}</> : null;
};

export default If;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should live in _includes/partials/_system-requirements.mdx

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go with that for now, thanks. Moved.

@ctauchen ctauchen changed the title WIP: Adds conditional formatting component Adds conditional formatting component Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants