-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'js/4647-create-separate-module-for-the-design-system-as…
…-per-tamagui-guidelines' into 'master' Create separate module for the design system as per Tamagui guidelines See merge request minds/mobile-native!2026
- Loading branch information
Showing
45 changed files
with
3,330 additions
and
55 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
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
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
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,36 @@ | ||
{ | ||
"name": "@minds/ui", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"types": "./types/index.d.ts", | ||
"main": "dist/cjs", | ||
"module": "dist/esm", | ||
"module:jsx": "dist/jsx", | ||
"files": [ | ||
"types", | ||
"src", | ||
"dist" | ||
], | ||
"sideEffects": [ | ||
"*.css" | ||
], | ||
"dependencies": { | ||
"@tamagui/animations-react-native": "^1.0.3", | ||
"@tamagui/button": "^1.0.3", | ||
"@tamagui/core": "^1.0.3", | ||
"@tamagui/font-size": "^1.0.3", | ||
"@tamagui/get-button-sized": "^1.0.3", | ||
"@tamagui/helpers-tamagui": "^1.0.3", | ||
"@tamagui/react-native-media-driver": "^1.0.3", | ||
"@tamagui/shorthands": "^1.0.3", | ||
"@tamagui/stacks": "^1.0.3", | ||
"@tamagui/text": "^1.0.3" | ||
}, | ||
"scripts": { | ||
"build": "tamagui-build", | ||
"watch": "tamagui-build --watch" | ||
}, | ||
"devDependencies": { | ||
"@tamagui/build": "^1.0.3" | ||
} | ||
} |
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,117 @@ | ||
import React, { forwardRef } from 'react'; | ||
import { TamaguiElement, styled, themeable, GetProps } from '@tamagui/core'; | ||
import { getButtonSized } from '@tamagui/get-button-sized'; | ||
import { ThemeableStack } from '@tamagui/stacks'; | ||
import { SizableText } from '@tamagui/text'; | ||
import { ButtonProps, useButton } from './buttonHelpers'; | ||
|
||
const NAME = 'Button'; | ||
|
||
export const ButtonFrame = styled(ThemeableStack, { | ||
name: NAME, | ||
tag: 'button', | ||
focusable: true, | ||
hoverTheme: true, | ||
pressTheme: true, | ||
backgrounded: true, | ||
borderWidth: 1, | ||
borderColor: 'transparent', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
flexWrap: 'nowrap', | ||
flexDirection: 'row', | ||
borderRadius: 100_000, | ||
|
||
// if we wanted this only when pressable = true, we'd need to merge variants? | ||
cursor: 'pointer', | ||
|
||
pressStyle: { | ||
borderColor: 'transparent', | ||
}, | ||
|
||
hoverStyle: { | ||
borderColor: 'transparent', | ||
}, | ||
|
||
focusStyle: { | ||
borderColor: '$borderColorFocus', | ||
}, | ||
|
||
variants: { | ||
size: { | ||
'...size': getButtonSized, | ||
}, | ||
sSize: { | ||
xl: (_, extra) => getButtonSized('$5', extra), | ||
l: (_, extra) => getButtonSized('$4', extra), | ||
m: (_, extra) => getButtonSized('$3.5', extra), | ||
s: (_, extra) => getButtonSized('$3', extra), | ||
}, | ||
disabled: { | ||
true: { | ||
pointerEvents: 'none', | ||
opacity: 0.5, | ||
}, | ||
}, | ||
} as const, | ||
|
||
defaultVariants: { | ||
size: '$3', | ||
}, | ||
}); | ||
|
||
export const ButtonText = styled(SizableText, { | ||
name: NAME, | ||
userSelect: 'none', | ||
cursor: 'pointer', | ||
// flexGrow 1 leads to inconsistent native style where text pushes to start of view | ||
flexGrow: 0, | ||
flexShrink: 1, | ||
ellipse: true, | ||
|
||
variants: { | ||
sSize: { | ||
xl: { | ||
size: '$5', | ||
}, | ||
l: { | ||
size: '$4', | ||
}, | ||
m: { | ||
size: '$3.5', | ||
}, | ||
s: { | ||
size: '$3', | ||
}, | ||
}, | ||
} as const, | ||
defaultVariants: { | ||
size: '$3.5', | ||
}, | ||
}); | ||
|
||
type ButtonFrameProps = GetProps<typeof ButtonFrame>; | ||
const ButtonComponent = forwardRef<TamaguiElement, ButtonFrameProps>( | ||
(props, ref) => { | ||
const { props: buttonProps } = useButton(props as ButtonProps, ButtonText); | ||
return <ButtonFrame {...buttonProps} ref={ref} />; | ||
}, | ||
); | ||
|
||
export const buttonStaticConfig = { | ||
inlineProps: new Set([ | ||
// text props go here (can't really optimize them, but we never fully extract button anyway) | ||
// may be able to remove this entirely, as the compiler / runtime have gotten better | ||
'color', | ||
'fontWeight', | ||
'fontSize', | ||
'fontFamily', | ||
'letterSpacing', | ||
'textAlign', | ||
]), | ||
}; | ||
|
||
export const Button = ButtonFrame.extractable( | ||
themeable(ButtonComponent, ButtonFrame.staticConfig), | ||
buttonStaticConfig, | ||
); |
Oops, something went wrong.