-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1614 from gluestack/feat/storybook-newComp
fix: added useTheme and useStyled in doc and storybook
- Loading branch information
Showing
8 changed files
with
187 additions
and
1 deletion.
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
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
41 changes: 41 additions & 0 deletions
41
example/storybook/src/styled/hooks/useStyled/index.stories.mdx
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,41 @@ | ||
--- | ||
title: useStyled | gluestack-ui | ||
description: useStyled is a custom hook that returns a configuration object encompassing aliases, components, global styles, plugins, and tokens. This configuration facilitates easy access to essential styling elements and global functionalities for components | ||
showHeader: false | ||
--- | ||
|
||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
|
||
<Meta title="styled/Hooks/useStyled" /> | ||
|
||
# useStyled | ||
|
||
**useStyled** is a custom hook that returns a configuration object encompassing aliases, components, global styles, plugins, and tokens. This configuration facilitates easy access to essential styling elements and global functionalities for components. | ||
|
||
### Import | ||
|
||
To use the `useStyled` in your project, import `useStyled` from `@gluestack-style/react`. as Demonstrated below. | ||
|
||
```jsx | ||
import { useStyled } from '@gluestack-style/react'; | ||
``` | ||
|
||
Let's use our `useStyled` value to give background color to `View` from `react-native`. | ||
|
||
```jsx | ||
import { View } from 'react-native'; | ||
import { useStyled } from '@gluestack-style/react'; | ||
|
||
const Example = () => { | ||
const styled = useStyled(); | ||
return ( | ||
<View | ||
style={{ | ||
width: 100, | ||
height: 100, | ||
backgroundColor: styled.config.tokens.colors.primary500, | ||
}} | ||
/> | ||
); | ||
}; | ||
``` |
35 changes: 35 additions & 0 deletions
35
example/storybook/src/styled/hooks/useTheme/index.stories.mdx
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,35 @@ | ||
--- | ||
title: useTheme | gluestack-ui | ||
description: useTheme is a custom hook which returns an array of active themes | ||
showHeader: false | ||
--- | ||
|
||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
|
||
<Meta title="styled/Hooks/useTheme" /> | ||
|
||
# useTheme | ||
|
||
**useTheme** is a custom hook which returns an array of active themes. | ||
|
||
### Import | ||
|
||
To use the `useTheme` in your project, import `useTheme` from `@gluestack-style/react`. as Demonstrated below. | ||
|
||
```jsx | ||
import { useTheme } from '@gluestack-style/react'; | ||
``` | ||
|
||
Demonstration of `useTheme` | ||
|
||
```jsx | ||
import { View } from 'react-native'; | ||
import { useTheme } from '@gluestack-style/react'; | ||
|
||
const Example = () => { | ||
const theme = useTheme() | ||
return ( | ||
<View>{/* Do something with the theme */}</View> | ||
); | ||
}; | ||
``` |
41 changes: 41 additions & 0 deletions
41
example/storybook/src/ui/hooks/use-styled/index.stories.mdx
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,41 @@ | ||
--- | ||
title: useStyled | gluestack-ui | ||
description: useStyled is a custom hook that returns a configuration object encompassing aliases, components, global styles, plugins, and tokens. This configuration facilitates easy access to essential styling elements and global functionalities for components | ||
showHeader: false | ||
--- | ||
|
||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
|
||
<Meta title="ui/Hooks/useStyled" /> | ||
|
||
# useStyled | ||
|
||
**useStyled** is a custom hook that returns a configuration object encompassing aliases, components, global styles, plugins, and tokens. This configuration facilitates easy access to essential styling elements and global functionalities for components. | ||
|
||
### Import | ||
|
||
To use the `useStyled` in your project, import `useStyled` from `@gluestack-ui/themed` as demonstrated below. | ||
|
||
```jsx | ||
import { useStyled } from '@gluestack-ui/themed'; | ||
``` | ||
|
||
Let's use our `useStyled` value to give background color to `View` from `react-native`. | ||
|
||
```jsx | ||
import { View } from 'react-native'; | ||
import { useStyled } from '@gluestack-ui/themed'; | ||
|
||
const Example = () => { | ||
const styled = useStyled(); | ||
return ( | ||
<View | ||
style={{ | ||
width: 100, | ||
height: 100, | ||
backgroundColor: styled.config.tokens.colors.primary500, | ||
}} | ||
/> | ||
); | ||
}; | ||
``` |
9 changes: 9 additions & 0 deletions
9
example/storybook/src/ui/hooks/use-styled/use-styled.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,9 @@ | ||
import type { ComponentMeta } from '@storybook/react-native'; | ||
import useStyled from './useStyled'; | ||
const useStyledMeta: ComponentMeta<typeof useStyled> = { | ||
title: 'stories/hooks/useStyled', | ||
component: useStyled, | ||
}; | ||
|
||
export default useStyledMeta; | ||
export { useStyled }; |
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 { View } from 'react-native'; | ||
import { useStyled } from '@gluestack-ui/themed'; | ||
import React from 'react'; | ||
|
||
export default function Example({}: any) { | ||
const styled = useStyled(); | ||
return ( | ||
<View | ||
style={{ | ||
width: 100, | ||
height: 100, | ||
backgroundColor: styled.config.tokens.colors.primary500, | ||
}} | ||
/> | ||
); | ||
} |
35 changes: 35 additions & 0 deletions
35
example/storybook/src/ui/hooks/use-theme/index.stories.mdx
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,35 @@ | ||
--- | ||
title: useTheme | gluestack-ui | ||
description: useTheme is a custom hook which returns an array of active themes | ||
showHeader: false | ||
--- | ||
|
||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
|
||
<Meta title="ui/Hooks/useTheme" /> | ||
|
||
# useTheme | ||
|
||
**useTheme** is a custom hook which returns an array of active themes. | ||
|
||
### Import | ||
|
||
To use the `useTheme` in your project, import `useTheme` from `@gluestack-ui/themed` as demonstrated below. | ||
|
||
```jsx | ||
import { useTheme } from '@gluestack-ui/themed'; | ||
``` | ||
|
||
Demonstration of `useTheme` | ||
|
||
```jsx | ||
import { View } from 'react-native'; | ||
import { useTheme } from '@gluestack-ui/themed'; | ||
|
||
const Example = () => { | ||
const theme = useTheme() | ||
return ( | ||
<View>{/* Do something with the theme */}</View> | ||
); | ||
}; | ||
``` |