-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdds-*): add Dropzone component
- Loading branch information
1 parent
e27bf3e
commit 3ed5a8b
Showing
26 changed files
with
593 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/sdds-cs/src/components/Dropzone/Dropzone.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { css, dropzoneTokens } from '@salutejs/plasma-new-hope/styled-components'; | ||
|
||
export const config = { | ||
defaults: { | ||
view: 'default', | ||
size: 'm', | ||
}, | ||
variations: { | ||
view: { | ||
default: css` | ||
${dropzoneTokens.background}: var(--surface-solid-card); | ||
${dropzoneTokens.backgroundHover}: var(--surface-solid-card-hover); | ||
${dropzoneTokens.overlayColorActive}: var(--overlay-soft); | ||
${dropzoneTokens.borderColor}: var(--outline-solid-primary); | ||
${dropzoneTokens.borderColorHover}: var(--outline-solid-primary-hover); | ||
${dropzoneTokens.borderColorActive}: var(--outline-accent); | ||
${dropzoneTokens.titleColor}: var(--text-primary); | ||
${dropzoneTokens.descriptionColor}: var(--text-secondary); | ||
`, | ||
}, | ||
size: { | ||
m: css` | ||
${dropzoneTokens.padding}: 1.5rem; | ||
${dropzoneTokens.borderRadius}: 1.25rem; | ||
${dropzoneTokens.contentWrapperGap}: 0.75rem; | ||
${dropzoneTokens.contentGap}: 0.375rem; | ||
${dropzoneTokens.contentColumnGap}: 0.5rem; | ||
${dropzoneTokens.titleFontFamily}: var(--plasma-typo-h4-font-family); | ||
${dropzoneTokens.titleFontSize}: var(--plasma-typo-h4-font-size); | ||
${dropzoneTokens.titleFontStyle}: var(--plasma-typo-h4-font-style); | ||
${dropzoneTokens.titleFontWeight}: var(--plasma-typo-h4-bold-font-weight); | ||
${dropzoneTokens.titleLetterSpacing}: var(--plasma-typo-h4-letter-spacing); | ||
${dropzoneTokens.titleLineHeight}: var(--plasma-typo-h4-line-height); | ||
${dropzoneTokens.descriptionFontFamily}: var(--plasma-typo-body-s-font-family); | ||
${dropzoneTokens.descriptionFontSize}: var(--plasma-typo-body-s-font-size); | ||
${dropzoneTokens.descriptionFontStyle}: var(--plasma-typo-body-s-font-style); | ||
${dropzoneTokens.descriptionFontWeight}: var(--plasma-typo-body-s-font-weight); | ||
${dropzoneTokens.descriptionLetterSpacing}: var(--plasma-typo-body-s-letter-spacing); | ||
${dropzoneTokens.descriptionLineHeight}: var(--plasma-typo-body-s-line-height); | ||
`, | ||
}, | ||
disabled: { | ||
true: css` | ||
${dropzoneTokens.disabledOpacity}: 0.4; | ||
`, | ||
}, | ||
}, | ||
}; |
58 changes: 58 additions & 0 deletions
58
packages/sdds-cs/src/components/Dropzone/Dropzone.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { ComponentProps } from 'react'; | ||
import type { StoryObj, Meta } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { InSpacingDecorator, disableProps } from '@salutejs/plasma-sb-utils'; | ||
|
||
import { Dropzone } from './Dropzone'; | ||
|
||
const onDragEnter = action('onDragEnter'); | ||
const onDragLeave = action('onDragLeave'); | ||
const onDrop = action('onDrop'); | ||
const onChange = action('onChange'); | ||
const onChoseFiles = action('onChoseFiles'); | ||
|
||
const iconPlacements = ['top', 'left']; | ||
|
||
const meta: Meta<typeof Dropzone> = { | ||
title: 'Controls/Dropzone', | ||
component: Dropzone, | ||
decorators: [InSpacingDecorator], | ||
argTypes: { | ||
iconPlacement: { | ||
options: iconPlacements, | ||
control: { | ||
type: 'inline-radio', | ||
}, | ||
defaultValue: 'top', | ||
}, | ||
...disableProps(['view', 'size']), | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type StoryPropsDefault = ComponentProps<typeof Dropzone>; | ||
|
||
export const Default: StoryObj<StoryPropsDefault> = { | ||
args: { | ||
iconPlacement: 'top', | ||
width: 400, | ||
height: 280, | ||
disabled: false, | ||
stretch: false, | ||
title: 'Click to upload', | ||
description: 'or drag and drop files here', | ||
}, | ||
render: (args) => ( | ||
<div style={{ height: '100vh' }}> | ||
<Dropzone | ||
{...args} | ||
onDragEnter={onDragEnter} | ||
onDragLeave={onDragLeave} | ||
onDrop={onDrop} | ||
onChange={onChange} | ||
onChoseFiles={onChoseFiles} | ||
/> | ||
</div> | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { dropzoneConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components'; | ||
|
||
import { config } from './Dropzone.config'; | ||
|
||
const mergedConfig = mergeConfig(dropzoneConfig, config); | ||
|
||
export const Dropzone = component(mergedConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Dropzone } from './Dropzone'; | ||
export { dropzoneTokens, dropzoneClasses } from '@salutejs/plasma-new-hope/styled-components'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/sdds-dfa/src/components/Dropzone/Dropzone.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { css, dropzoneTokens } from '@salutejs/plasma-new-hope/styled-components'; | ||
|
||
export const config = { | ||
defaults: { | ||
view: 'default', | ||
size: 'm', | ||
}, | ||
variations: { | ||
view: { | ||
default: css` | ||
${dropzoneTokens.background}: var(--surface-solid-card); | ||
${dropzoneTokens.backgroundHover}: var(--surface-solid-card-hover); | ||
${dropzoneTokens.overlayColorActive}: var(--overlay-soft); | ||
${dropzoneTokens.borderColor}: var(--outline-solid-secondary); | ||
${dropzoneTokens.borderColorHover}: var(--outline-solid-secondary-hover); | ||
${dropzoneTokens.borderColorActive}: var(--outline-accent); | ||
${dropzoneTokens.titleColor}: var(--text-primary); | ||
${dropzoneTokens.descriptionColor}: var(--text-secondary); | ||
`, | ||
}, | ||
size: { | ||
m: css` | ||
${dropzoneTokens.padding}: 1.5rem; | ||
${dropzoneTokens.borderRadius}: 1.25rem; | ||
${dropzoneTokens.contentWrapperGap}: 0.75rem; | ||
${dropzoneTokens.contentGap}: 0.375rem; | ||
${dropzoneTokens.contentColumnGap}: 0.5rem; | ||
${dropzoneTokens.titleFontFamily}: var(--plasma-typo-h4-font-family); | ||
${dropzoneTokens.titleFontSize}: var(--plasma-typo-h4-font-size); | ||
${dropzoneTokens.titleFontStyle}: var(--plasma-typo-h4-font-style); | ||
${dropzoneTokens.titleFontWeight}: var(--plasma-typo-h4-bold-font-weight); | ||
${dropzoneTokens.titleLetterSpacing}: var(--plasma-typo-h4-letter-spacing); | ||
${dropzoneTokens.titleLineHeight}: var(--plasma-typo-h4-line-height); | ||
${dropzoneTokens.descriptionFontFamily}: var(--plasma-typo-body-s-font-family); | ||
${dropzoneTokens.descriptionFontSize}: var(--plasma-typo-body-s-font-size); | ||
${dropzoneTokens.descriptionFontStyle}: var(--plasma-typo-body-s-font-style); | ||
${dropzoneTokens.descriptionFontWeight}: var(--plasma-typo-body-s-font-weight); | ||
${dropzoneTokens.descriptionLetterSpacing}: var(--plasma-typo-body-s-letter-spacing); | ||
${dropzoneTokens.descriptionLineHeight}: var(--plasma-typo-body-s-line-height); | ||
`, | ||
}, | ||
disabled: { | ||
true: css` | ||
${dropzoneTokens.disabledOpacity}: 0.4; | ||
`, | ||
}, | ||
}, | ||
}; |
58 changes: 58 additions & 0 deletions
58
packages/sdds-dfa/src/components/Dropzone/Dropzone.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { ComponentProps } from 'react'; | ||
import type { StoryObj, Meta } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { InSpacingDecorator, disableProps } from '@salutejs/plasma-sb-utils'; | ||
|
||
import { Dropzone } from './Dropzone'; | ||
|
||
const onDragEnter = action('onDragEnter'); | ||
const onDragLeave = action('onDragLeave'); | ||
const onDrop = action('onDrop'); | ||
const onChange = action('onChange'); | ||
const onChoseFiles = action('onChoseFiles'); | ||
|
||
const iconPlacements = ['top', 'left']; | ||
|
||
const meta: Meta<typeof Dropzone> = { | ||
title: 'Controls/Dropzone', | ||
component: Dropzone, | ||
decorators: [InSpacingDecorator], | ||
argTypes: { | ||
iconPlacement: { | ||
options: iconPlacements, | ||
control: { | ||
type: 'inline-radio', | ||
}, | ||
defaultValue: 'top', | ||
}, | ||
...disableProps(['view', 'size']), | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type StoryPropsDefault = ComponentProps<typeof Dropzone>; | ||
|
||
export const Default: StoryObj<StoryPropsDefault> = { | ||
args: { | ||
iconPlacement: 'top', | ||
width: 400, | ||
height: 280, | ||
disabled: false, | ||
stretch: false, | ||
title: 'Click to upload', | ||
description: 'or drag and drop files here', | ||
}, | ||
render: (args) => ( | ||
<div style={{ height: '100vh' }}> | ||
<Dropzone | ||
{...args} | ||
onDragEnter={onDragEnter} | ||
onDragLeave={onDragLeave} | ||
onDrop={onDrop} | ||
onChange={onChange} | ||
onChoseFiles={onChoseFiles} | ||
/> | ||
</div> | ||
), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { dropzoneConfig, component, mergeConfig } from '@salutejs/plasma-new-hope/styled-components'; | ||
|
||
import { config } from './Dropzone.config'; | ||
|
||
const mergedConfig = mergeConfig(dropzoneConfig, config); | ||
|
||
export const Dropzone = component(mergedConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { Dropzone } from './Dropzone'; | ||
export { dropzoneTokens, dropzoneClasses } from '@salutejs/plasma-new-hope/styled-components'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.