This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #436 from gluestack/release/@gluestack-style/babel…
…[email protected] Release/@gluestack style/babel plugin styled [email protected]
- Loading branch information
Showing
39 changed files
with
1,348 additions
and
965 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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
module.exports = { | ||
extends: 'next', | ||
root: true, | ||
}; |
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
58 changes: 58 additions & 0 deletions
58
example/storybook/src/hooks/useBreakPointValue/breakPointValue.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 from 'react'; | ||
import { | ||
useMediaQuery, | ||
styled, | ||
useBreakpointValue, | ||
} from '@gluestack-style/react'; | ||
import Wrapper from '../../components/Wrapper'; | ||
import { View, Text } from 'react-native'; | ||
|
||
const StyledBox = styled(View, { | ||
w: 100, | ||
h: 100, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
bg: '$cyan500', | ||
rounded: '$md', | ||
}) as any; | ||
|
||
const StyledText = styled(Text, { | ||
color: '$white', | ||
fontSize: '$md', | ||
}); | ||
|
||
export const breakPointValueStory = () => { | ||
return ( | ||
<Wrapper> | ||
<BreakPointValue /> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
const BreakPointValue = () => { | ||
const flexDir = useBreakpointValue({ | ||
base: 'column', | ||
sm: 'row', | ||
}); | ||
|
||
return ( | ||
<View | ||
style={{ | ||
flexDirection: flexDir, | ||
gap: 10, | ||
}} | ||
> | ||
<StyledBox> | ||
<StyledText>Universal</StyledText> | ||
</StyledBox> | ||
<StyledBox> | ||
<StyledText>Performant</StyledText> | ||
</StyledBox> | ||
<StyledBox> | ||
<StyledText>Accessible</StyledText> | ||
</StyledBox> | ||
</View> | ||
); | ||
}; | ||
export { useMediaQuery }; | ||
export default breakPointValueStory; |
49 changes: 49 additions & 0 deletions
49
example/storybook/src/hooks/useBreakPointValue/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,49 @@ | ||
--- | ||
title: useTheme | gluestack-style | ||
description: useTheme | ||
showHeader: false | ||
--- | ||
|
||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
|
||
<Meta title="hooks/useBreakpointValue" /> | ||
|
||
# useBreakpointValue | ||
|
||
**useBreakpointValue** is a custom hook to returns the value for the current breakpoint based on the provided responsive values object. It is also responsive to window resizing and returning the appropriate value according to the new window size. | ||
|
||
### Import | ||
|
||
To use the `useBreakpointValue` in your project, import `useBreakpointValue` from `@gluestack-style/react`. as Demonstrated below. | ||
|
||
```jsx | ||
import { useBreakpointValue } from '@gluestack-style/react'; | ||
``` | ||
|
||
```jsx | ||
const BreakPointValue = () => { | ||
const flexDir = useBreakpointValue({ | ||
base: 'column', | ||
sm: 'row', | ||
}); | ||
|
||
return ( | ||
<View | ||
style={{ | ||
flexDirection: flexDir, | ||
gap: 10, | ||
}} | ||
> | ||
<StyledBox> | ||
<StyledText>Universal</StyledText> | ||
</StyledBox> | ||
<StyledBox> | ||
<StyledText>Performant</StyledText> | ||
</StyledBox> | ||
<StyledBox> | ||
<StyledText>Accessible</StyledText> | ||
</StyledBox> | ||
</View> | ||
); | ||
}; | ||
``` |
11 changes: 11 additions & 0 deletions
11
example/storybook/src/hooks/useBreakPointValue/useBreakPointValue.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,11 @@ | ||
import type { ComponentMeta } from '@storybook/react-native'; | ||
import { breakPointValueStory } from './breakPointValue'; | ||
|
||
const MediaQueryMeta: ComponentMeta<typeof breakPointValueStory> = { | ||
title: 'hooks/stories/useMediaQuery', | ||
component: breakPointValueStory, | ||
}; | ||
|
||
export { breakPointValueStory } from './breakPointValue'; | ||
|
||
export default MediaQueryMeta; |
41 changes: 41 additions & 0 deletions
41
example/storybook/src/hooks/useColorMode/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: useColorMode | gluestack-style | ||
description: useColorMode | ||
showHeader: false | ||
--- | ||
|
||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
|
||
<Meta title="hooks/useColorMode" /> | ||
|
||
# useColorMode | ||
|
||
**useColorMode** is a custom hook which return current color mode. | ||
|
||
### Import | ||
|
||
To use the useColorMode in your project, import `useColorMode` from `@gluestack-style/react`. as Demonstrated below. | ||
|
||
```jsx | ||
import { useColorMode } from '@gluestack-style/react'; | ||
``` | ||
|
||
Let's use our `useColorMode` value to give background color to `View` from `react-native`. | ||
|
||
```jsx | ||
import { View } from 'react-native'; | ||
import { useColorMode } from '@gluestack-style/react'; | ||
|
||
function Example() { | ||
const colorMode = useColorMode(); | ||
return ( | ||
<View | ||
style={{ | ||
width: 100, | ||
height: 100, | ||
backgroundColor: colorMode === 'light' ? 'white' : 'black', | ||
}} | ||
/> | ||
); | ||
} | ||
``` |
76 changes: 76 additions & 0 deletions
76
example/storybook/src/hooks/useMediaQuery/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,76 @@ | ||
--- | ||
title: useMediaQuery | gluestack-style | ||
description: Learn to use the useMediaQuery hook in React Native for detecting media query matches and creating responsive UI elements, despite limitations like performance impacts and lack of typings. | ||
canonical: https://style.gluestack.io/ | ||
--- | ||
|
||
import { Canvas, Meta, Story } from '@storybook/addon-docs'; | ||
import { Text, View } from 'react-native'; | ||
import { Button, AppProvider, CodePreview } from '@gluestack/design-system'; | ||
import { config } from '../../components/nb.config'; | ||
import { StyledProvider, styled } from '@gluestack-style/react'; | ||
import { useMediaQuery } from './maxWidth'; | ||
|
||
<Meta title="hooks/useMediaQuery" /> | ||
|
||
# useMediaQuery | ||
|
||
The useMediaQuery custom hook is designed to assist in detecting matches between one or more media queries. However, due to the lack of native support for media queries in React Native, the capabilities of useMediaQuery are somewhat constrained. | ||
|
||
## Import: | ||
|
||
```bash | ||
import { useMediaQuery } from '@gluestack-style/react'; | ||
``` | ||
### Example: | ||
<AppProvider> | ||
<CodePreview | ||
mb="$6" | ||
showArgsController={false} | ||
metaData={{ | ||
scope: { | ||
styled, | ||
Provider: StyledProvider, | ||
config, | ||
Text, | ||
View, | ||
useMediaQuery, | ||
}, | ||
code: ` | ||
function MediaQuery() { | ||
const StyledBox = styled(View, { | ||
w: 300, | ||
h: 300, | ||
bg: '$green500', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
variants: { | ||
size: { | ||
lg: { | ||
bg: '$blue500', | ||
}, | ||
}, | ||
}, | ||
}); | ||
const StyledText = styled(Text, { | ||
color: '$white', | ||
fontSize: '$xl', | ||
}); | ||
const [isSmallScreen] = useMediaQuery({ | ||
maxWidth: 700, | ||
}); | ||
return ( | ||
<Provider config={config}> | ||
<StyledBox size={isSmallScreen ? 'sm' : 'lg'}> | ||
<StyledText>{isSmallScreen ? 'Mobile' : 'Desktop'}</StyledText> | ||
</StyledBox> | ||
</Provider> | ||
); | ||
} | ||
`, | ||
}} | ||
/> | ||
</AppProvider> |
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,42 @@ | ||
import React from 'react'; | ||
import { useMediaQuery, styled } from '@gluestack-style/react'; | ||
import Wrapper from '../../components/Wrapper'; | ||
import { View, Text } from 'react-native'; | ||
|
||
const StyledBox = styled(View, { | ||
w: 300, | ||
h: 300, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
variants: { | ||
size: { | ||
sm: { | ||
bg: '$green500', | ||
}, | ||
lg: { | ||
bg: '$blue500', | ||
}, | ||
}, | ||
}, | ||
}) as any; | ||
|
||
const StyledText = styled(Text, { | ||
color: '$white', | ||
fontSize: '$xl', | ||
}); | ||
|
||
export const maxWidth = () => { | ||
const [isSmallScreen] = useMediaQuery({ | ||
maxWidth: 700, | ||
}); | ||
|
||
return ( | ||
<Wrapper> | ||
<StyledBox size={isSmallScreen ? 'sm' : 'lg'}> | ||
<StyledText>{isSmallScreen ? 'Mobile' : 'Desktop'}</StyledText> | ||
</StyledBox> | ||
</Wrapper> | ||
); | ||
}; | ||
export { useMediaQuery }; | ||
export default maxWidth; |
11 changes: 11 additions & 0 deletions
11
example/storybook/src/hooks/useMediaQuery/useMediaQuery.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,11 @@ | ||
import type { ComponentMeta } from '@storybook/react-native'; | ||
import maxWidth from './maxWidth'; | ||
|
||
const MediaQueryMeta: ComponentMeta<typeof maxWidth> = { | ||
title: 'hooks/stories/useMediaQuery', | ||
component: maxWidth, | ||
}; | ||
|
||
export { maxWidth } from './maxWidth'; | ||
|
||
export default MediaQueryMeta; |
Oops, something went wrong.