-
Notifications
You must be signed in to change notification settings - Fork 116
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview succeeded!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for calico-docs-preview-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
578b7b8
to
0418319
Compare
@ronanc-tigera Here's the component in action. Anything I should be doing differently here before I proceed? |
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'}> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
src/___new___/components/If/index.js
Outdated
@@ -0,0 +1,7 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
_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:
DOCS review:
Additional information:
Merge checklist: