-
Notifications
You must be signed in to change notification settings - Fork 11
Add @shopify/restyle
#175
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
Draft
DominicSherman
wants to merge
8
commits into
master
Choose a base branch
from
add-shopify
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add @shopify/restyle
#175
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9fc32e7
Convert intro and login screens
DominicSherman b7053cf
Clean up registration scrteen
DominicSherman 7c91286
Fix up all the storybook things
DominicSherman 56c123b
Fix up login page
DominicSherman b4b78c3
Fix TS and add pr verify
DominicSherman cd721c6
Add PR verify for template repo
DominicSherman adee6f0
Move into workflows
DominicSherman 67604ea
Color updates
DominicSherman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,24 @@ | ||
| name: PR Verify | ||
|
|
||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - 'master' | ||
| - 'main' | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v1 | ||
| - name: PR Verify | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: 10.16.0 | ||
| - name: Verify lint, TS, and tests | ||
| run: | | ||
| cd template | ||
| yarn | ||
| yarn ci | ||
This file contains hidden or 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,8 @@ | ||
| module.exports = { | ||
| root: true, | ||
| extends: ['plugin:echobind/react-native'], | ||
| rules: { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were both causing issues for me, not sure if we should add them to the plugin or leave them here |
||
| 'import/namespace': 0, | ||
| '@typescript-eslint/explicit-function-return-type': 0 | ||
| } | ||
| }; | ||
This file contains hidden or 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,23 @@ | ||
| name: PR Verify | ||
|
|
||
| on: | ||
| push: | ||
| branches-ignore: | ||
| - 'master' | ||
| - 'main' | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v1 | ||
| - name: PR Verify | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: 10.16.0 | ||
| - name: Verify lint, TS, and tests | ||
| run: | | ||
| yarn | ||
| yarn ci |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,83 +1,31 @@ | ||
| import React, { FC } from 'react'; | ||
| import { ActivityIndicator } from 'react-native'; | ||
| import { | ||
| backgroundColor, | ||
| BorderProps, | ||
| ColorProps, | ||
| SpaceProps, | ||
| FlexProps, | ||
| LayoutProps, | ||
| } from 'styled-system'; | ||
| import { createRestyleComponent, createVariant, VariantProps } from '@shopify/restyle'; | ||
| import React from 'react'; | ||
|
|
||
| import { Container } from '../Container'; | ||
| import { Theme } from '../../theme'; | ||
| import { useVariantValue } from '../../utils/theme-utils/theme-utils'; | ||
| import { Text } from '../Text'; | ||
| import { Touchable } from '../Touchable'; | ||
| import { colors } from '../../styles'; | ||
| import { AccessbilityRole } from '../../types/AccessibilityRole'; | ||
| import { Touchable, TouchableProps } from '../Touchable'; | ||
|
|
||
| interface ButtonProps { | ||
| /** | ||
| * Overrides the text that's read by the screen reader when the user interacts with the element. By default, the | ||
| * label is constructed by traversing all the children and accumulating all the Text nodes separated by space. | ||
| */ | ||
| accessibilityLabel: string; | ||
| /** Accessibility Role tells a person using either VoiceOver on iOS or TalkBack on Android the type of element that is focused on. */ | ||
| accessbilityRole?: AccessbilityRole; | ||
| /** disabled button state */ | ||
| disabled?: boolean; | ||
| /** loading button state */ | ||
| loading?: boolean; | ||
| /** the text label of the button */ | ||
| label: string; | ||
| /** the callback to be invoked onPress */ | ||
| onPress: () => void; | ||
| } | ||
| type ButtonProps = TouchableProps & VariantProps<Theme, 'buttonVariants'>; | ||
|
|
||
| type ComponentProps = ButtonProps & BorderProps & ColorProps & SpaceProps & FlexProps & LayoutProps; | ||
| const VariantRestyleComponent = createVariant({ | ||
| themeKey: 'buttonVariants', | ||
| }); | ||
|
|
||
| const ButtonWrapper = createRestyleComponent<ButtonProps, Theme>( | ||
| [VariantRestyleComponent], | ||
| Touchable | ||
| ); | ||
|
|
||
| /** | ||
| * notes: | ||
| * - restricting inner text style from being directly configurable to avoid style prop conflicts | ||
| * - if button is disabled it will not render a touchableOpacity at all | ||
| * A simple button | ||
| */ | ||
| export const Button: FC<ComponentProps> = ({ | ||
| accessibilityLabel, | ||
| label, | ||
| onPress, | ||
| disabled, | ||
| loading, | ||
| color: componentColor, | ||
| ...props | ||
| }) => { | ||
| const ButtonContainer = disabled ? Container : Touchable; | ||
| const onPressAction = loading ? null : onPress; | ||
| export const Button = ({ children, ...props }: ButtonProps) => { | ||
| const textStyle = useVariantValue('buttonVariants', 'textStyle', props.variant); | ||
|
|
||
| return ( | ||
| <ButtonContainer | ||
| centerContent | ||
| bg={disabled ? colors.disabled : backgroundColor} | ||
| borderRadius={40} | ||
| height={50} | ||
| width={0.6} | ||
| accessibilityLabel={accessibilityLabel} | ||
| onPress={onPressAction} | ||
| disabled={disabled} | ||
| {...props} | ||
| > | ||
| {loading ? ( | ||
| <ActivityIndicator /> | ||
| ) : ( | ||
| <Text color={disabled ? colors.gray : componentColor} fontWeight="bold" fontSize={2}> | ||
| {label} | ||
| </Text> | ||
| )} | ||
| </ButtonContainer> | ||
| <ButtonWrapper {...props}> | ||
| <Text {...textStyle}>{children}</Text> | ||
| </ButtonWrapper> | ||
| ); | ||
| }; | ||
|
|
||
| Button.defaultProps = { | ||
| disabled: false, | ||
| borderColor: colors.transparent, | ||
| borderWidth: 1, | ||
| backgroundColor: colors.orange, | ||
| }; |
This file contains hidden or 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 +1 @@ | ||
| export * from './Button'; | ||
| export * from './Button'; |
This file contains hidden or 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,64 +1,18 @@ | ||
| import { | ||
| BorderProps, | ||
| borders, | ||
| color, | ||
| ColorProps, | ||
| flexbox, | ||
| FlexProps, | ||
| layout, | ||
| space, | ||
| SpaceProps, | ||
| } from 'styled-system'; | ||
| import styled from '@emotion/native'; | ||
| import { BoxProps, createBox } from '@shopify/restyle'; | ||
| import React from 'react'; | ||
|
|
||
| import { margins } from '../../styles'; | ||
| import { Theme } from '../../theme'; | ||
|
|
||
| interface ContainerProps { | ||
| /** applies "flex: 1" style */ | ||
| fill?: boolean; | ||
| /** applies "width: 100%" style */ | ||
| fullWidth?: boolean; | ||
| /** centers content both vertically and horizontally */ | ||
| centerContent?: boolean; | ||
| /** | ||
| * applies default horizontal screen margins. | ||
| * decoupled from Screen component to make layout-building more flexible. | ||
| */ | ||
| screenMargins?: boolean; | ||
| } | ||
| /** | ||
| * Renders a View with @shopify/restyle functionality. | ||
| */ | ||
| export const Container = createBox<Theme>(); | ||
|
|
||
| type ComponentProps = ContainerProps & BorderProps & ColorProps & FlexProps & SpaceProps; | ||
| export type ContainerProps = React.ComponentProps<typeof Container> & BoxProps<Theme>; | ||
|
|
||
| /** | ||
| * This is our primitive View component with styled-system props applied | ||
| * Renders a container with children that are horizontally and vertically centered. | ||
| */ | ||
| export const Container = styled.View<ComponentProps>` | ||
| ${space}; | ||
| ${color}; | ||
| ${borders}; | ||
| ${layout}; | ||
| ${flexbox}; | ||
| ${props => | ||
| props.fill && | ||
| ` | ||
| flex: 1; | ||
| `} | ||
| ${props => | ||
| props.fullWidth && | ||
| ` | ||
| width: 100%; | ||
| `} | ||
| ${props => | ||
| props.centerContent && | ||
| ` | ||
| justifyContent: center; | ||
| alignItems: center; | ||
| `} | ||
| ${props => | ||
| props.screenMargins && | ||
| ` | ||
| paddingHorizontal: ${margins.screenMargin}; | ||
| `} | ||
| `; | ||
|
|
||
| Container.defaultProps = {}; | ||
| export const CenteredContainer = (props: ContainerProps): React.ReactElement => ( | ||
| <Container alignItems="center" justifyContent="center" {...props} /> | ||
| ); |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will add safety to the template repository to ensure we aren't introducing changes that will cause this to fail in an out of the box app. I can remove this as well or move it to circle CI