Skip to content

Commit

Permalink
fix(component-stage): fix and improve component-stage
Browse files Browse the repository at this point in the history
  • Loading branch information
GaroGabrielyan committed Dec 22, 2023
1 parent d3849b2 commit b244edb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
16 changes: 14 additions & 2 deletions .storybook/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { componentStage } from '../stories/assets/storybook.globals';
const ComponentStageMessage = ({ stage, currentVersion }) => (
<>
This component is <b>{stage}</b>, to learn more about the <b>{stage}</b> stage{' '}
<a href={`${currentVersion}/?path=/docs/introduction--page#component-stages`}>read here</a>.
<a href={`${currentVersion}/?path=/docs/introduction--docs#component-stages`}>read here</a>.
</>
);

Expand All @@ -18,7 +18,19 @@ const CustomDecorator = ({ children }) => {
const [allowRenderChildren, setAllowRenderChildren] = useState(false);
const isDarkMode = useDarkMode();
let type;
const componentStageProp = children?.props?.componentStage || children?.props?.children?.props?.componentStage;
const componentStageGetter = (children, num) => {
return (
Array.isArray(children?.props?.children) &&
children?.props?.children.length >= num &&
children?.props?.children[num]?.props?.componentStage
);
};

const componentStageProp =
children?.props?.componentStage ||
children?.props?.children?.props?.componentStage ||
componentStageGetter(children, 1) ||
componentStageGetter(children, 0);

const currentVersion = useMemo(
() =>
Expand Down
11 changes: 10 additions & 1 deletion stories/organisms/Table/Table.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export default {
<div>
<Button>headerActions</Button>
</div>
)
),
componentStage: {
type: componentStage.deprecated
}
}
};

Expand Down Expand Up @@ -611,3 +614,9 @@ export const ControlledComboTable = ({ ...args }) => {
</>
);
};

ControlledComboTable.args = {
componentStage: {
type: componentStage.deprecated
}
};

0 comments on commit b244edb

Please sign in to comment.