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

plasma-infra(b2c): Migrate to CSF 3 [Migrate SB 7 Part 1] #833

Merged
merged 39 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f9d7963
chore(plasma-b2c): migrate to CSF 3 [AudioPlayer]
Yakutoc Oct 12, 2023
d64a1d0
fix(plasma-hope): fix typo [AudioPlayer]
Yakutoc Oct 12, 2023
d65663b
chore(plasma-b2c): migrate to CSF 3 [Badge]
Yakutoc Oct 12, 2023
a4e16a5
chore(plasma-b2c): migrate to CSF 3 [Button]
Yakutoc Oct 12, 2023
f1ad6a3
chore(plasma-b2c): migrate to CSF 3 [Calendar]
Yakutoc Oct 12, 2023
138a30b
chore(plasma-b2c): migrate to CSF 3 [Card]
Yakutoc Oct 13, 2023
8656531
chore(plasma-b2c): migrate to CSF 3 [Carousel]
Yakutoc Oct 13, 2023
d8b02f1
chore(plasma-b2c): migrate to CSF 3 [Cell]
Yakutoc Oct 13, 2023
494cf28
chore(plasma-b2c): migrate to CSF 3 [Checkbox]
Yakutoc Oct 13, 2023
91fbbc9
chore(plasma-b2c): migrate to CSF 3 [Dropdown]
Yakutoc Oct 13, 2023
3a3790d
chore(plasma-b2c): migrate to CSF 3 [Editable]
Yakutoc Oct 13, 2023
ac289d8
chore(plasma-b2c): migrate to CSF 3 [ElasticGrid]
Yakutoc Oct 13, 2023
1a40802
chore(plasma-b2c): migrate to CSF 3 [Grid]
Yakutoc Oct 13, 2023
a0c72bc
chore(plasma-b2c): migrate to CSF 3 [Image]
Yakutoc Oct 13, 2023
c3ef4bc
chore(plasma-b2c): migrate to CSF 3 [Link]
Yakutoc Oct 13, 2023
3034e76
chore(plasma-b2c): migrate to CSF 3 [Modal]
Yakutoc Oct 13, 2023
63245de
chore(plasma-b2c): migrate to CSF 3 [Notification]
Yakutoc Oct 13, 2023
234850e
chore(plasma-b2c): migrate to CSF 3 [PaginationDots]
Yakutoc Oct 13, 2023
1722511
chore(plasma-b2c): migrate to CSF 3 [PreviewGallery]
Yakutoc Oct 13, 2023
6803fb0
chore(plasma-b2c): migrate to CSF 3 [Price]
Yakutoc Oct 13, 2023
de2fa1e
chore(plasma-b2c): migrate to CSF 3 [Progress]
Yakutoc Oct 13, 2023
d5bc5d5
chore(plasma-b2c): migrate to CSF 3 [Skeleton]
Yakutoc Oct 13, 2023
45bc76b
chore(plasma-b2c): migrate to CSF 3 [Slider]
Yakutoc Oct 26, 2023
2342b80
chore(plasma-b2c): migrate to CSF 3 [Spinner]
Yakutoc Oct 26, 2023
22f2039
chore(plasma-b2c): migrate to CSF 3 [Switch]
Yakutoc Oct 26, 2023
17742ff
chore(plasma-b2c): migrate to CSF 3 [Toast]
Yakutoc Oct 26, 2023
9ba8dee
chore(plasma-b2c): migrate to CSF 3 [Tooltip]
Yakutoc Oct 26, 2023
3883bab
chore(plasma-b2c): migrate to CSF 3 [Typography]
Yakutoc Oct 26, 2023
756f672
chore(plasma-b2c): migrate to CSF 3 [Upload]
Yakutoc Oct 26, 2023
e9ca31e
chore(plasma-b2c): migrate to CSF 3 [UploadAudio]
Yakutoc Oct 26, 2023
e15ed63
chore(plasma-b2c): migrate to CSF 3 [UploadVisual]
Yakutoc Oct 26, 2023
ac430c7
chore(plasma-b2c): migrate to CSF 3 [ModalBase]
Yakutoc Oct 13, 2023
4da4b5a
chore(plasma-b2c): migrate to CSF 3 [Popover]
Yakutoc Oct 27, 2023
1a8bfd9
chore(plasma-b2c): migrate to CSF 3 [PopupBase]
Yakutoc Oct 27, 2023
e53da2b
chore(plasma-b2c): migrate to CSF 3 [Radiobox]
Yakutoc Oct 27, 2023
6e33dee
chore(plasma-b2c): migrate to CSF 3 [Select]
Yakutoc Oct 27, 2023
e80156a
chore(plasma-b2c): migrate to CSF 3 [Tabs]
Yakutoc Oct 27, 2023
ad29398
chore(plasma-b2c): migrate to CSF 3 [TextArea]
Yakutoc Oct 27, 2023
eef3a9c
chore(plasma-b2c): migrate to CSF 3 [TextField]
Yakutoc Oct 27, 2023
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
@@ -1,24 +1,23 @@
import React, { useState, useCallback } from 'react';
import styled from 'styled-components';
import { Story, Meta } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react';
import { InSpacingDecorator } from '@salutejs/plasma-sb-utils';

import { AudioPlayer } from '.';
import type { AudioPlayerProps } from '.';

export default {
const meta: Meta<AudioPlayerProps> = {
title: 'Controls/AudioPlayer',
component: AudioPlayer,
argTypes: {},
decorators: [InSpacingDecorator],
} as Meta;
};

export default meta;

const StyledWrapper = styled.div`
width: 23.75rem;
`;

interface StoryProps extends AudioPlayerProps {}

const song = {
name: 'I’m Not Okay',
duration: 128,
Expand All @@ -28,7 +27,7 @@ const song = {
canDelete: true,
};

export const Base: Story<StoryProps> = ({ ...rest }) => {
const StoryAudioPlayer = (props: AudioPlayerProps) => {
const [state, setState] = useState({
isSelected: false,
isPlaying: false,
Expand Down Expand Up @@ -68,8 +67,12 @@ export const Base: Story<StoryProps> = ({ ...rest }) => {
event.stopPropagation();
onPlay();
}}
{...rest}
{...props}
/>
</StyledWrapper>
);
};

export const Base: StoryObj<AudioPlayerProps> = {
render: (args) => <StoryAudioPlayer {...args} />,
};
32 changes: 17 additions & 15 deletions packages/plasma-b2c/src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React from 'react';
import { Story, Meta } from '@storybook/react';
import type { StoryObj, Meta } from '@storybook/react';
import { IconSettings } from '@salutejs/plasma-icons';
import { disableProps, InSpacingDecorator } from '@salutejs/plasma-sb-utils';

import { Badge, badgeSizes, badgeViews, BadgeSize, BadgeView, BadgeProps } from '.';
import { Badge, badgeSizes, badgeViews, BadgeSize, BadgeView } from '.';
import type { BadgeProps } from '.';

const sizeKeys = Object.keys(badgeSizes) as BadgeSize[];
const viewKeys = Object.keys(badgeViews) as BadgeView[];

const propsToDisable = ['contentLeft', 'circled', 'theme', 'as', 'forwardedAs'];

export default {
const meta: Meta<BadgeProps> = {
title: 'Content/Badge',
component: Badge,
decorators: [InSpacingDecorator],
Expand All @@ -27,17 +26,20 @@ export default {
type: 'select',
},
},
...disableProps(propsToDisable),
...disableProps(['contentLeft', 'circled', 'theme', 'as', 'forwardedAs']),
},
} as Meta;
};

export const Default: Story<BadgeProps & { enableIcon: boolean }> = ({ enableIcon, ...rest }) => (
<Badge contentLeft={enableIcon && <IconSettings color="inherit" size="xs" />} {...rest} />
);
export default meta;

Default.args = {
text: 'Badge',
size: 'l',
view: 'primary',
enableIcon: false,
export const Default: StoryObj<BadgeProps & { enableIcon: boolean }> = {
args: {
text: 'Badge',
size: 'l',
view: 'primary',
enableIcon: false,
},
render: ({ enableIcon, ...rest }) => (
<Badge contentLeft={enableIcon && <IconSettings color="inherit" size="xs" />} {...rest} />
),
};
160 changes: 90 additions & 70 deletions packages/plasma-b2c/src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React, { useState, useCallback, useRef } from 'react';
import { Story, Meta } from '@storybook/react';
import type { StoryObj, Meta } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { IconPlaceholder, disableProps, InSpacingDecorator } from '@salutejs/plasma-sb-utils';

import { Button, ButtonProps } from '.';
import { Button } from '.';
import type { ButtonProps } from '.';

type StoryButtonProps = ButtonProps & { contentType: string; isLoading: boolean };

const views = ['primary', 'secondary', 'success', 'critical'];

const sizes = ['l', 'm', 's', 'xs', 'xxs'];

const pins = [
'square-square',
'circle-circle',
Expand All @@ -23,20 +28,15 @@ const onClick = action('onClick');
const onFocus = action('onFocus');
const onBlur = action('onBlur');

const propsToDisable = [
'theme',
'as',
'forwardedAs',
'contentLeft',
'contentRight',
'shiftLeft',
'shiftRight',
'blur',
'stretch',
'square',
];
const iconSize = {
l: 's',
m: 's',
s: 's',
xs: 'xs',
xxs: 'xs',
};

export default {
const meta: Meta<StoryButtonProps> = {
title: 'Controls/Button',
decorators: [InSpacingDecorator],
argTypes: {
Expand All @@ -46,11 +46,6 @@ export default {
type: 'select',
},
},
text: {
control: {
type: 'text',
},
},
size: {
options: sizes,
control: {
Expand All @@ -69,38 +64,68 @@ export default {
type: 'select',
},
},
...disableProps(propsToDisable),
...disableProps([
'theme',
'as',
'forwardedAs',
'contentLeft',
'contentRight',
'shiftLeft',
'shiftRight',
'blur',
'stretch',
'square',
'onClick',
'onFocus',
'onBlur',
]),
},
} as Meta;

type ButtonStoryProps = ButtonProps & { contentType: string; isLoading: boolean };

const args: ButtonStoryProps = {
view: 'primary',
size: 'l',
pin: 'square-square',
disabled: false,
outlined: true,
focused: false,
text: 'Label',
contentType: 'Text',
isLoading: false,
onClick,
onFocus,
onBlur,
};

const iconSize = {
l: 's',
m: 's',
s: 's',
xs: 'xs',
xxs: 'xs',
export default meta;

type Story = StoryObj<StoryButtonProps>;

const StoryBaseButton: Story = {
args: {
view: 'primary',
size: 'l',
pin: 'square-square',
disabled: false,
outlined: true,
focused: false,
text: 'Label',
contentType: 'Text',
isLoading: false,
onClick,
onFocus,
onBlur,
},
};

export const Default: Story<ButtonStoryProps> = ({ contentType, text, ...rest }) => {
return (
export const Default: Story = {
...StoryBaseButton,
render: ({ contentType, text, ...rest }) => {
return (
<Button
text={contentType !== 'Left' && text}
contentLeft={
(contentType === 'Left' || contentType === 'Text+Left') && (
<IconPlaceholder size={iconSize[rest.size]} />
)
}
contentRight={contentType === 'Text+Right' && <IconPlaceholder size={iconSize[rest.size]} />}
{...rest}
/>
);
},
};

export const Anchor: Story = {
...StoryBaseButton,
render: ({ contentType, text, ...rest }) => (
<Button
as="a"
text={contentType !== 'Left' && text}
contentLeft={
(contentType === 'Left' || contentType === 'Text+Left') && (
Expand All @@ -110,31 +135,10 @@ export const Default: Story<ButtonStoryProps> = ({ contentType, text, ...rest })
contentRight={contentType === 'Text+Right' && <IconPlaceholder size={iconSize[rest.size]} />}
{...rest}
/>
);
),
};

Default.args = args;

export const Anchor: Story<ButtonStoryProps> = ({ contentType, text, ...rest }) => (
<Button
as="a"
text={contentType !== 'Left' && text}
contentLeft={
(contentType === 'Left' || contentType === 'Text+Left') && <IconPlaceholder size={iconSize[rest.size]} />
}
contentRight={contentType === 'Text+Right' && <IconPlaceholder size={iconSize[rest.size]} />}
{...rest}
/>
);

Anchor.args = args;

const argsLoading: ButtonStoryProps = {
...args,
text: 'Start loading',
};

export const Loading: Story<ButtonStoryProps> = ({ contentType, isLoading, text, onClick: _onClick, ...rest }) => {
const StoryButtonLoading = ({ contentType, isLoading, text, onClick: _onClick, ...rest }: StoryButtonProps) => {
const [loading, setLoading] = useState(isLoading);
const [count, setCount] = useState(0);
const intervalId = useRef<number | undefined>();
Expand Down Expand Up @@ -179,4 +183,20 @@ export const Loading: Story<ButtonStoryProps> = ({ contentType, isLoading, text,
);
};

Loading.args = argsLoading;
export const Loading: Story = {
args: {
view: 'primary',
size: 'l',
pin: 'square-square',
disabled: false,
outlined: true,
focused: false,
contentType: 'Text',
text: 'Start loading',
isLoading: false,
onClick,
onFocus,
onBlur,
},
render: (args) => <StoryButtonLoading {...args} />,
};
Loading
Loading