Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const parameters = {

docs: {
/** Disable the `code` tab */
codePanel: false,
codePanel: true,
},

controls: {
Expand All @@ -227,6 +227,8 @@ const parameters = {
actions: {
disable: true,
},

tags: ['autodocs'],
};

const preview: Preview = {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
"@azure/storage-blob": "^12.9.0",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@storybook/addon-docs": "^10.1.9",
"@storybook/addon-docs": "^10.1.11",
"@storybook/addon-webpack5-compiler-swc": "^4.0.2",
"@storybook/react-webpack5": "^10.1.4",
"@storybook/react-webpack5": "^10.1.11",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.95",
"@swc/jest": "^0.2.29",
Expand Down Expand Up @@ -107,7 +107,7 @@
"es6-promise-pool": "^2.5.0",
"eslint": "^8.57.0",
"eslint-plugin-mistica-local-rules": "workspace:*",
"eslint-plugin-storybook": "^10.1.4",
"eslint-plugin-storybook": "^10.1.11",
"glob": "^7.2.0",
"gzip-size": "^6.0.0",
"husky": "^7.0.4",
Expand All @@ -134,11 +134,11 @@
"rollup-plugin-preserve-directives": "^0.2.0",
"semantic-release": "^19.0.2",
"serve-handler": "^6.1.5",
"storybook": "^10.1.4",
"storybook": "^10.1.11",
"style-loader": "^4.0.0",
"swc-loader": "^0.2.3",
"typescript": "^5.9.3",
"vite": "^4.5.0",
"vite": "^5.0.0",
"vite-plugin-no-bundle": "^2.0.3",
"webpack-react-component-name": "^5.0.5"
},
Expand Down
126 changes: 65 additions & 61 deletions src/__stories__/accordion-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ export default {
control: {type: 'select'},
},
},
decorators: [
(Story: any, context: any) => (
<ResponsiveLayout fullWidth variant={context.args.variantOutside || 'default'}>
<Box padding={16}>
<Story />
</Box>
</ResponsiveLayout>
),
],
};

type Args = {
Expand All @@ -55,7 +64,6 @@ const Template: StoryComponent<BoxedArgs & {type?: 'boxed'}> = ({
right,
singleOpen,
variant,
variantOutside,
type,
}) => {
const content = <Placeholder height={100} />;
Expand All @@ -79,66 +87,62 @@ const Template: StoryComponent<BoxedArgs & {type?: 'boxed'}> = ({
};

return (
<ResponsiveLayout fullWidth variant={variantOutside}>
<Box padding={16}>
<AccordionComponent singleOpen={singleOpen} dataAttributes={{testid: 'accordion'}}>
<ItemComponent
{...getAccordionItemContentProps()}
dataAttributes={{testid: 'accordion-item-1'}}
/>
<ItemComponent
{...getAccordionItemContentProps()}
asset={<IconThumbUpFilled size={24} />}
dataAttributes={{testid: 'accordion-item-2'}}
/>
<ItemComponent
{...getAccordionItemContentProps()}
asset={
<Circle backgroundColor={skinVars.colors.brandLow} size={40}>
<IconMobileDeviceRegular color={skinVars.colors.brand} />
</Circle>
}
dataAttributes={{testid: 'accordion-item-3'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Circle size={40} backgroundImage={laptopImg} />}
dataAttributes={{testid: 'accordion-item-4'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Image src={usingVrImg} height={80} aspectRatio="16:9" />}
dataAttributes={{testid: 'accordion-item-5'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Image src={personPortraitImg} width={80} aspectRatio="7:10" />}
dataAttributes={{testid: 'accordion-item-6'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Image src={touchImg} width={80} aspectRatio="1:1" />}
dataAttributes={{testid: 'accordion-item-7'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Avatar size={40} src={avatarImg} />}
dataAttributes={{testid: 'accordion-item-8'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Avatar size={40} initials="MS" />}
dataAttributes={{testid: 'accordion-item-9'}}
/>
</AccordionComponent>
</Box>
</ResponsiveLayout>
<AccordionComponent singleOpen={singleOpen} dataAttributes={{testid: 'accordion'}}>
<ItemComponent
{...getAccordionItemContentProps()}
dataAttributes={{testid: 'accordion-item-1'}}
/>
<ItemComponent
{...getAccordionItemContentProps()}
asset={<IconThumbUpFilled size={24} />}
dataAttributes={{testid: 'accordion-item-2'}}
/>
<ItemComponent
{...getAccordionItemContentProps()}
asset={
<Circle backgroundColor={skinVars.colors.brandLow} size={40}>
<IconMobileDeviceRegular color={skinVars.colors.brand} />
</Circle>
}
dataAttributes={{testid: 'accordion-item-3'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Circle size={40} backgroundImage={laptopImg} />}
dataAttributes={{testid: 'accordion-item-4'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Image src={usingVrImg} height={80} aspectRatio="16:9" />}
dataAttributes={{testid: 'accordion-item-5'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Image src={personPortraitImg} width={80} aspectRatio="7:10" />}
dataAttributes={{testid: 'accordion-item-6'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Image src={touchImg} width={80} aspectRatio="1:1" />}
dataAttributes={{testid: 'accordion-item-7'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Avatar size={40} src={avatarImg} />}
dataAttributes={{testid: 'accordion-item-8'}}
/>

<ItemComponent
{...getAccordionItemContentProps()}
asset={<Avatar size={40} initials="MS" />}
dataAttributes={{testid: 'accordion-item-9'}}
/>
</AccordionComponent>
);
};

Expand Down
15 changes: 10 additions & 5 deletions src/__stories__/align-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export default {
control: {type: 'range', min: 200, max: 400, step: 20},
},
},
decorators: [
(Story: any) => (
<div style={{display: 'inline-block', border: '1px solid red'}}>
<Story />
</div>
),
],
};

type Props = {
Expand All @@ -30,11 +37,9 @@ type Props = {

export const Default: StoryComponent<Props> = ({x, y, width, height}) => {
return (
<div style={{display: 'inline-block', border: '1px solid red'}}>
<Align width={width} height={height} x={x} y={y} dataAttributes={{testid: 'story'}}>
<Text2 regular>Content</Text2>
</Align>
</div>
<Align width={width} height={height} x={x} y={y} dataAttributes={{testid: 'story'}}>
<Text2 regular>Content</Text2>
</Align>
);
};

Expand Down
62 changes: 33 additions & 29 deletions src/__stories__/avatar-story.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
import * as React from 'react';
import {Avatar, IconBrainRegular, IconFireRegular, IconStarFilled, ResponsiveLayout, Box} from '..';
import { Avatar, IconBrainRegular, IconFireRegular, IconStarFilled, ResponsiveLayout, Box } from '..';
import avatarImg from './images/avatar.jpg';

import type {Variant} from '../theme-variant-context';
import type { Variant } from '../theme-variant-context';

const badgeOptions = ['true', 'false', 'undefined', '0', '1', '5', '10'];

export default {
title: 'Components/Avatar',
argTypes: {
size: {
control: {type: 'range', min: 24, max: 128, step: 4},
control: { type: 'range', min: 24, max: 128, step: 4 },
},
badge: {
options: badgeOptions,
control: {type: 'select'},
control: { type: 'select' },
},
icon: {
options: ['undefined', 'IconStarFilled', 'IconFireRegular', 'IconBrainRegular'],
control: {type: 'select'},
control: { type: 'select' },
},
variantOutside: {
options: ['default', 'brand', 'negative', 'alternative'],
control: {type: 'select'},
control: { type: 'select' },
},
},
parameters: {
fullScreen: true,
},
decorators: [
(Story: any, context: any) => (
<ResponsiveLayout variant={context.args.variantOutside || 'default'} fullWidth>
<Box padding={16} width="fit-content" dataAttributes={{ testid: 'avatar' }}>
<div
style={{
// prevent line-height from affecting the height of the container;
// happens when changing the base font size
lineHeight: 0,
}}
>
<Story />
</div>
</Box>
</ResponsiveLayout>
),
],
};

type Args = {
Expand All @@ -49,38 +66,25 @@ export const Default: StoryComponent<Args> = ({
badge,
src,
icon,
variantOutside,
hideImage,
hideInitials,
ariaLabel,
border,
}) => {
// eslint-disable-next-line no-eval
const badgeValue = badgeOptions.includes(badge) ? eval(badge) : undefined;
const Icon = {IconStarFilled, IconFireRegular, IconBrainRegular}[icon];
const Icon = { IconStarFilled, IconFireRegular, IconBrainRegular }[icon];

return (
<ResponsiveLayout variant={variantOutside} fullWidth>
<Box padding={16} width="fit-content" dataAttributes={{testid: 'avatar'}}>
<div
style={{
// prevent line-height from affecting the height of the container;
// happens when changing the base font size
lineHeight: 0,
}}
>
<Avatar
size={size}
src={hideImage ? undefined : src || undefined}
initials={hideInitials ? undefined : initials}
badge={badgeValue}
Icon={Icon}
aria-label={ariaLabel}
border={border}
/>
</div>
</Box>
</ResponsiveLayout>
<Avatar
size={size}
src={hideImage ? undefined : src || undefined}
initials={hideInitials ? undefined : initials}
badge={badgeValue}
Icon={Icon}
aria-label={ariaLabel}
border={border}
/>
);
};

Expand Down
33 changes: 19 additions & 14 deletions src/__stories__/badge-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,33 @@ export default {
},
},
parameters: {fullScreen: true},
decorators: [
(Story: any, context: any) => (
<ResponsiveLayout variant={context.args.variantOutside || 'default'} fullWidth>
<Box padding={16} width="fit-content" dataAttributes={{testid: 'content'}}>
<Story />
</Box>
</ResponsiveLayout>
),
],
};

type Args = {
variantOutside: Variant;
value: string;
};

export const Default: StoryComponent<Args> = ({variantOutside, value}) => {
export const Default: StoryComponent<Args> = ({value}) => {
return (
<ResponsiveLayout variant={variantOutside} fullWidth>
<Box padding={16} width="fit-content" dataAttributes={{testid: 'content'}}>
<Badge value={value !== 'undefined' ? +value : undefined}>
<Touchable
style={{display: 'inline-block', width: 24, height: 24}}
onPress={() => {}}
aria-label="Read notifications"
>
<IconBellFilled />
</Touchable>
</Badge>
</Box>
</ResponsiveLayout>
<Badge value={value !== 'undefined' ? +value : undefined}>
<Touchable
style={{display: 'inline-block', width: 24, height: 24}}
onPress={() => {}}
aria-label="Read notifications"
>
<IconBellFilled />
</Touchable>
</Badge>
);
};

Expand Down
Loading
Loading