-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plasma-b2c,star-ds): Add
FocusContainer
component
- Loading branch information
1 parent
6a5eac1
commit 1211b6c
Showing
12 changed files
with
288 additions
and
2 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
libraries/plasma-b2c/src/components/FocusContainer/FocusContainer.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,16 @@ | ||
import { Theme } from '@salutejs/core-components'; | ||
|
||
import { PlasmaB2CTheme } from '../ThemeProvider'; | ||
|
||
export const getConfig = ({ data, mode }: Theme<PlasmaB2CTheme>) => ({ | ||
defaults: {}, | ||
variations: { | ||
focused: { | ||
true: { | ||
focusedTextColor: data.color[mode].onLightTextPrimary, | ||
focusedBackgroundColor: data.color[mode].onDarkSurfaceSolidDefault, | ||
focusedScale: 1.05, | ||
}, | ||
}, | ||
}, | ||
}); |
81 changes: 81 additions & 0 deletions
81
libraries/plasma-b2c/src/components/FocusContainer/FocusContainer.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,81 @@ | ||
import { Text, View } from 'react-native'; | ||
import type { ComponentProps } from 'react'; | ||
import type { StoryObj, Meta } from '@storybook/react'; | ||
|
||
import { Checkbox } from '../Checkbox'; | ||
import { BodyM, H2 } from '../Typography'; | ||
|
||
import { FocusContainer } from './FocusContainer'; | ||
|
||
type StoryFocusContainerProps = ComponentProps<typeof FocusContainer>; | ||
|
||
const notes = ` | ||
| **Control** | **Description** | **Default** | | ||
|--------------------------|--------------------------|-------------| | ||
| unfocusedBackgroundColor | Фон карточки в не фокуса | | | ||
| unfocusedTextColor | Текст кнопки в не фокуса | | | ||
`; | ||
|
||
const meta: Meta<StoryFocusContainerProps> = { | ||
title: 'Components/FocusContainer', | ||
component: FocusContainer, | ||
parameters: { | ||
notes, | ||
}, | ||
args: { | ||
unfocusedBackgroundColor: '#ffffff1f', | ||
unfocusedTextColor: 'lightblue', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const StoryDefault = (props: StoryFocusContainerProps) => { | ||
return ( | ||
<FocusContainer | ||
unfocusedBackgroundColor={props.unfocusedBackgroundColor} | ||
unfocusedTextColor={props.unfocusedTextColor} | ||
> | ||
{({ focusedBackgroundColor, focused, focusedScale, focusedTextColor }) => { | ||
const styles = { | ||
root: { | ||
width: 300, | ||
height: 150, | ||
padding: 16, | ||
}, | ||
background: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
bottom: 0, | ||
right: 0, | ||
borderRadius: 16, | ||
backgroundColor: focusedBackgroundColor, | ||
transform: [ | ||
{ | ||
scale: focusedScale, | ||
}, | ||
], | ||
} as any, | ||
text: { | ||
color: focusedTextColor, | ||
}, | ||
}; | ||
|
||
return ( | ||
<View style={styles.root}> | ||
<View style={styles.background} /> | ||
<Text style={styles.text}>Text</Text> | ||
<Checkbox label="Label" focused={focused} /> | ||
<H2 focused={focused}>Title</H2> | ||
<BodyM focused={focused}>Subtitle</BodyM> | ||
</View> | ||
); | ||
}} | ||
</FocusContainer> | ||
); | ||
}; | ||
|
||
export const Default: StoryObj<StoryFocusContainerProps> = { | ||
render: (args) => <StoryDefault {...args} />, | ||
}; |
5 changes: 5 additions & 0 deletions
5
libraries/plasma-b2c/src/components/FocusContainer/FocusContainer.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,5 @@ | ||
import { focusContainerComponent } from '@salutejs/core-components'; | ||
|
||
import { getConfig } from './FocusContainer.config'; | ||
|
||
export const FocusContainer = focusContainerComponent(getConfig); |
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 @@ | ||
export { FocusContainer } from './FocusContainer'; |
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
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
16 changes: 16 additions & 0 deletions
16
libraries/star-ds/src/components/FocusContainer/FocusContainer.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,16 @@ | ||
import { Theme } from '@salutejs/core-components'; | ||
|
||
import { StylesSaluteTheme } from '../ThemeProvider'; | ||
|
||
export const getConfig = ({ data, mode }: Theme<StylesSaluteTheme>) => ({ | ||
defaults: {}, | ||
variations: { | ||
focused: { | ||
true: { | ||
focusedTextColor: data.color[mode].onLightTextPrimary, | ||
focusedBackgroundColor: data.color[mode].onDarkSurfaceSolidDefault, | ||
focusedScale: 1.05, | ||
}, | ||
}, | ||
}, | ||
}); |
81 changes: 81 additions & 0 deletions
81
libraries/star-ds/src/components/FocusContainer/FocusContainer.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,81 @@ | ||
import { Text, View } from 'react-native'; | ||
import type { ComponentProps } from 'react'; | ||
import type { StoryObj, Meta } from '@storybook/react'; | ||
|
||
import { Checkbox } from '../Checkbox'; | ||
import { BodyM, H2 } from '../Typography'; | ||
|
||
import { FocusContainer } from './FocusContainer'; | ||
|
||
type StoryFocusContainerProps = ComponentProps<typeof FocusContainer>; | ||
|
||
const notes = ` | ||
| **Control** | **Description** | **Default** | | ||
|--------------------------|--------------------------|-------------| | ||
| unfocusedBackgroundColor | Фон карточки в не фокуса | | | ||
| unfocusedTextColor | Текст кнопки в не фокуса | | | ||
`; | ||
|
||
const meta: Meta<StoryFocusContainerProps> = { | ||
title: 'Components/FocusContainer', | ||
component: FocusContainer, | ||
parameters: { | ||
notes, | ||
}, | ||
args: { | ||
unfocusedBackgroundColor: '#ffffff1f', | ||
unfocusedTextColor: 'lightblue', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const StoryDefault = (props: StoryFocusContainerProps) => { | ||
return ( | ||
<FocusContainer | ||
unfocusedBackgroundColor={props.unfocusedBackgroundColor} | ||
unfocusedTextColor={props.unfocusedTextColor} | ||
> | ||
{({ focusedBackgroundColor, focused, focusedScale, focusedTextColor }) => { | ||
const styles = { | ||
root: { | ||
width: 300, | ||
height: 150, | ||
padding: 16, | ||
}, | ||
background: { | ||
position: 'absolute', | ||
top: 0, | ||
left: 0, | ||
bottom: 0, | ||
right: 0, | ||
borderRadius: 16, | ||
backgroundColor: focusedBackgroundColor, | ||
transform: [ | ||
{ | ||
scale: focusedScale, | ||
}, | ||
], | ||
} as any, | ||
text: { | ||
color: focusedTextColor, | ||
}, | ||
}; | ||
|
||
return ( | ||
<View style={styles.root}> | ||
<View style={styles.background} /> | ||
<Text style={styles.text}>Text</Text> | ||
<Checkbox label="Label" focused={focused} /> | ||
<H2 focused={focused}>Title</H2> | ||
<BodyM focused={focused}>Subtitle</BodyM> | ||
</View> | ||
); | ||
}} | ||
</FocusContainer> | ||
); | ||
}; | ||
|
||
export const Default: StoryObj<StoryFocusContainerProps> = { | ||
render: (args) => <StoryDefault {...args} />, | ||
}; |
5 changes: 5 additions & 0 deletions
5
libraries/star-ds/src/components/FocusContainer/FocusContainer.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,5 @@ | ||
import { focusContainerComponent } from '@salutejs/core-components'; | ||
|
||
import { getConfig } from './FocusContainer.config'; | ||
|
||
export const FocusContainer = focusContainerComponent(getConfig); |
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 @@ | ||
export { FocusContainer } from './FocusContainer'; |
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
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