Skip to content

Commit

Permalink
Fix theme and tab stories for kitchen sink
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed May 15, 2024
1 parent 1ad4cf8 commit 4409e30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
6 changes: 4 additions & 2 deletions tgui/packages/tgui/debug/KitchenSink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const getStories = () => r.keys().map((path) => r(path));

export const KitchenSink = (props) => {
const { panel } = props;
const [theme] = useState(null);
const [theme, setTheme] = useState(null);
const [pageIndex, setPageIndex] = useState(0);
const stories = getStories();
const story = stories[pageIndex];
Expand All @@ -48,7 +48,9 @@ export const KitchenSink = (props) => {
</Section>
</Flex.Item>
<Flex.Item position="relative" grow={1}>
<Layout.Content scrollable>{story.meta.render()}</Layout.Content>
<Layout.Content scrollable>
{story.meta.render(theme, setTheme)}
</Layout.Content>
</Flex.Item>
</Flex>
</Layout>
Expand Down
19 changes: 9 additions & 10 deletions tgui/packages/tgui/stories/Tabs.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,41 +94,40 @@ const Story = (props) => {
</Button.Checkbox>
</Section>
<Section fitted>
<TabsPrefab />
<TabsPrefab tabProps={tabProps} />
</Section>
<Section title="Normal section">
<TabsPrefab />
<TabsPrefab tabProps={tabProps} />
Some text
</Section>
<Section>
Section-less tabs appear the same as tabs in a fitted section:
</Section>
<TabsPrefab />
<TabsPrefab tabProps={tabProps} />
</>
);
};

const TabsPrefab = (props) => {
const [tabIndex, setTabIndex] = useState(0);
const [tabProps] = useState({});
return (
<Tabs
vertical={tabProps.vertical}
fluid={tabProps.fluid}
textAlign={tabProps.centered && 'center'}
vertical={props.tabProps.vertical}
fluid={props.tabProps.fluid}
textAlign={props.tabProps.centered && 'center'}
>
{TAB_RANGE.map((text, i) => (
<Tabs.Tab
key={i}
selected={i === tabIndex}
icon={tabProps.icon && 'info-circle'}
icon={props.tabProps.icon && 'info-circle'}
leftSlot={
tabProps.leftSlot && (
props.tabProps.leftSlot && (
<Button circular compact color="transparent" icon="times" />
)
}
rightSlot={
tabProps.rightSlot && (
props.tabProps.rightSlot && (
<Button circular compact color="transparent" icon="times" />
)
}
Expand Down
8 changes: 3 additions & 5 deletions tgui/packages/tgui/stories/Themes.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@
* @license MIT
*/

import { useLocalState } from '../backend';
import { Input, LabeledList, Section } from '../components';

export const meta = {
title: 'Themes',
render: () => <Story />,
render: (theme, setTheme) => <Story theme={theme} setTheme={setTheme} />,
};

const Story = (props) => {
const [theme, setTheme] = useLocalState('kitchenSinkTheme');
return (
<Section>
<LabeledList>
<LabeledList.Item label="Use theme">
<Input
placeholder="theme_name"
value={theme}
onInput={(e, value) => setTheme(value)}
value={props.theme}
onInput={(e, value) => props.setTheme(value)}
/>
</LabeledList.Item>
</LabeledList>
Expand Down

0 comments on commit 4409e30

Please sign in to comment.