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

fix(storybook): list story #2856

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
TrophyIcon,
} from '@codecademy/gamut-icons';
import { Keyhole } from '@codecademy/gamut-illustrations';
import { ColorMode } from '@codecademy/gamut-styles';
import { Background } from '@codecademy/gamut-styles';
import { useState } from 'react';
import * as React from 'react';

Expand Down Expand Up @@ -75,7 +75,6 @@ export const DemoCardTemplate: React.FC = (args) => {
flexDirection="column"
height="8rem"
bg="palePink"
borderRadius={100}
justifyContent="center"
alignItems="center"
p={8}
Expand All @@ -90,140 +89,146 @@ export const DemoCardTemplate: React.FC = (args) => {
);
};

export const CondensedTemplate: React.FC<typeof List> = (args, { mode }) => (
<ColorMode mode={mode}>
<List {...args}>
{rows.map(({ name, role, ship }, i, _, key = `example-row-${i}`) => (
<ListRow key={key}>
<ListCol size="lg" type="header">
<Text fontWeight={700} truncate="ellipsis" truncateLines={1}>
{name}
</Text>
</ListCol>
<ListCol size="lg">
<Text
variant="p-small"
color="text-disabled"
truncate="ellipsis"
truncateLines={1}
>
{role}
</Text>
</ListCol>
<ListCol size="lg" fill>
<Text
variant="p-small"
color="text-disabled"
truncate="ellipsis"
truncateLines={1}
>
{ship}
</Text>
</ListCol>
<ListCol size="sm">
<Text variant="p-small" color="text-disabled" lineHeight="title">
<StreakIcon verticalAlign="bottom" mr={8} />
87%
</Text>
</ListCol>
<ListCol size="sm">
<Text variant="p-small" color="text-disabled" lineHeight="title">
<TrophyIcon verticalAlign="bottom" mr={8} />
48%
</Text>
</ListCol>
<ListCol size="sm">
<Text variant="p-small" color="text-disabled" lineHeight="title">
<StarIcon verticalAlign="bottom" mr={8} />
66%
</Text>
</ListCol>
<ListCol>
<FillButton size="small">Engage</FillButton>
</ListCol>
<ListCol type="control">
<IconButton icon={MiniKebabMenuIcon} size="small" tip="Engage!" />
<IconButton icon={MiniDeleteIcon} size="small" />
</ListCol>
</ListRow>
))}
</List>
</ColorMode>
export const CondensedTemplate: React.FC<typeof List> = (args) => (
<List {...args}>
{rows.map(({ name, role, ship }, i, _, key = `example-row-${i}`) => (
<ListRow key={key}>
<ListCol size="lg" type="header">
<Text fontWeight={700} truncate="ellipsis" truncateLines={1}>
{name}
</Text>
</ListCol>
<ListCol size="lg">
<Text
variant="p-small"
color="text-disabled"
truncate="ellipsis"
truncateLines={1}
>
{role}
</Text>
</ListCol>
<ListCol size="lg" fill>
<Text
variant="p-small"
color="text-disabled"
truncate="ellipsis"
truncateLines={1}
>
{ship}
</Text>
</ListCol>
<ListCol size="sm">
<Text variant="p-small" color="text-disabled" lineHeight="title">
<StreakIcon verticalAlign="bottom" mr={8} />
87%
</Text>
</ListCol>
<ListCol size="sm">
<Text variant="p-small" color="text-disabled" lineHeight="title">
<TrophyIcon verticalAlign="bottom" mr={8} />
48%
</Text>
</ListCol>
<ListCol size="sm">
<Text variant="p-small" color="text-disabled" lineHeight="title">
<StarIcon verticalAlign="bottom" mr={8} />
66%
</Text>
</ListCol>
<ListCol>
<FillButton size="small">Engage</FillButton>
</ListCol>
<ListCol type="control">
<IconButton
icon={MiniKebabMenuIcon}
size="small"
tip="Options"
tipProps={{ alignment: 'bottom-center', placement: 'floating' }}
/>
<IconButton
icon={MiniDeleteIcon}
size="small"
tip="Delete"
tipProps={{ alignment: 'bottom-center', placement: 'floating' }}
/>
</ListCol>
</ListRow>
))}
</List>
);

export const NormalTemplate: React.FC<typeof List> = (args, { mode }) => (
<ColorMode mode={mode}>
<List {...args}>
{rows.map(({ name, role, ship }, i, _, key = `example-row-${i}`) => (
<ListRow key={key}>
<ListCol size="lg" type="header">
<FlexBox column>
<Text
color="text-disabled"
textTransform="uppercase"
variant="p-small"
>
{ship}
</Text>
<Text variant="title-xs">{name}</Text>
</FlexBox>
</ListCol>
<ListCol size="md" fill>
<FlexBox column>
<Text
color="text-disabled"
textTransform="uppercase"
variant="p-small"
>
Rank
</Text>
<Text variant="title-xs">{role}</Text>
</FlexBox>
</ListCol>
<ListCol fill size="sm">
export const NormalTemplate: React.FC<typeof List> = (args) => (
<List {...args}>
{rows.map(({ name, role, ship }, i, _, key = `example-row-${i}`) => (
<ListRow key={key}>
<ListCol size="lg" type="header">
<FlexBox column>
<Text
variant="p-small"
color="text-disabled"
lineHeight="title"
mt={4}
>
<StreakIcon size={18} verticalAlign="middle" mr={8} mb={4} />
87%
</Text>
</ListCol>
<ListCol fill size="sm">
<Text
textTransform="uppercase"
variant="p-small"
color="text-disabled"
lineHeight="title"
mt={4}
>
<TrophyIcon size={18} verticalAlign="middle" mr={8} mb={4} />
48%
{ship}
</Text>
</ListCol>
<ListCol fill size="sm">
<Text variant="title-xs">{name}</Text>
</FlexBox>
</ListCol>
<ListCol size="md" fill>
<FlexBox column>
<Text
variant="p-small"
color="text-disabled"
lineHeight="title"
mt={4}
textTransform="uppercase"
variant="p-small"
>
<StarIcon size={18} verticalAlign="middle" mr={8} mb={4} />
66%
Rank
</Text>
</ListCol>
<ListCol size="lg" type="control">
<TextButton mr={16}>Hail</TextButton>
<FillButton>Engage</FillButton>
</ListCol>
</ListRow>
))}
</List>
</ColorMode>
<Text variant="title-xs">{role}</Text>
</FlexBox>
</ListCol>
<ListCol fill size="sm">
<Text
variant="p-small"
color="text-disabled"
lineHeight="title"
mt={4}
>
<StreakIcon size={18} verticalAlign="middle" mr={8} mb={4} />
87%
</Text>
</ListCol>
<ListCol fill size="sm">
<Text
variant="p-small"
color="text-disabled"
lineHeight="title"
mt={4}
>
<TrophyIcon size={18} verticalAlign="middle" mr={8} mb={4} />
48%
</Text>
</ListCol>
<ListCol fill size="sm">
<Text
variant="p-small"
color="text-disabled"
lineHeight="title"
mt={4}
>
<StarIcon size={18} verticalAlign="middle" mr={8} mb={4} />
66%
</Text>
</ListCol>
<ListCol size="lg" type="control">
<TextButton mr={16}>Hail</TextButton>
<FillButton>Engage</FillButton>
</ListCol>
</ListRow>
))}
</List>
);

const sizes = ['content', 'sm', 'md', 'lg', 'xl'];
const sizes = ['content', 'sm', 'md', 'lg', 'xl'] as const;

export const ColumnTemplate: React.FC<typeof List> = (args) => {
return (
Expand Down Expand Up @@ -349,8 +354,18 @@ export const ResponsiveTemplate: React.FC<typeof List> = (args) => {
</Text>
</ListCol>
<ListCol type="control">
<IconButton icon={MiniKebabMenuIcon} size="small" />
<IconButton icon={MiniDeleteIcon} size="small" />
<IconButton
icon={MiniKebabMenuIcon}
size="small"
tip="Options"
tipProps={{ placement: 'floating' }}
/>
<IconButton
icon={MiniDeleteIcon}
size="small"
tip="Delete"
tipProps={{ placement: 'floating' }}
/>
</ListCol>
</ListRow>
</List>
Expand Down Expand Up @@ -484,34 +499,32 @@ export const ExpandableButtonClickRow: React.FC<{
<ExpandedColumns name={name} role={role} ship={ship} />
<ListCol size="lg" type="control">
<TextButton>Hail</TextButton>
<IconButton onClick={() => setExpanded(!isExpanded)}>
<TextButton onClick={() => setExpanded(!isExpanded)}>
<Rotation rotated={isExpanded}>
<MiniChevronDownIcon />
</Rotation>
</IconButton>
</TextButton>
</ListCol>
</ListRow>
);
};

export const ExpandedTemplateRowClick: React.FC<
ListProps & { mode: 'light' | 'dark' }
> = ({ mode, variant }) => (
<ColorMode bg="black" mode={mode}>
export const ExpandedTemplateRowClick: React.FC<ListProps> = ({ variant }) => (
<Background bg="black">
<Box p={8}>
<List variant={variant}>
{rows.map(({ name, role, ship }, i, _, key = `example-row-${i}`) => (
<ExpandableRowClick name={name} role={role} ship={ship} key={key} />
))}
</List>
</Box>
</ColorMode>
</Background>
);

export const ExpandedTemplateButtonClick: React.FC<
ListProps & { mode: 'light' | 'dark' }
> = ({ mode, variant }) => (
<ColorMode bg="black" mode={mode}>
export const ExpandedTemplateButtonClick: React.FC<ListProps> = ({
variant,
}) => (
<Background bg="black">
<Box p={8}>
<List variant={variant}>
{rows.map(({ name, role, ship }, i, _, key = `example-row-${i}`) => (
Expand All @@ -524,5 +537,5 @@ export const ExpandedTemplateButtonClick: React.FC<
))}
</List>
</Box>
</ColorMode>
</Background>
);
Loading