-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
871a332
commit 692f284
Showing
8 changed files
with
183 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { createAnimations } from "@tamagui/animations-react-native"; | ||
|
||
export const animations = createAnimations({ | ||
"100ms": { | ||
type: "timing", | ||
duration: 100, | ||
}, | ||
bouncy: { | ||
damping: 9, | ||
mass: 0.9, | ||
stiffness: 150, | ||
}, | ||
lazy: { | ||
damping: 18, | ||
stiffness: 50, | ||
}, | ||
medium: { | ||
damping: 15, | ||
stiffness: 120, | ||
mass: 1, | ||
}, | ||
slow: { | ||
damping: 15, | ||
stiffness: 40, | ||
}, | ||
quick: { | ||
damping: 20, | ||
mass: 1.2, | ||
stiffness: 250, | ||
}, | ||
tooltip: { | ||
damping: 10, | ||
mass: 0.9, | ||
stiffness: 100, | ||
}, | ||
}); |
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,22 @@ | ||
{ | ||
"name": "@helixbridge/ui", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "index.js", | ||
"scripts": { | ||
"clean": "rm -rf node_modules .turbo dist", | ||
"build": "tamagui-build --skip-types", | ||
"watch": "tamagui-build --skip-types --watch" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@tamagui/get-token": "^1.110.1", | ||
"@tamagui/web": "^1.110.1", | ||
"react": "^18.2.0", | ||
"tamagui": "^1.110.1" | ||
}, | ||
"devDependencies": { | ||
"@helixbridge/tamagui-config": "workspace:*", | ||
"@tamagui/build": "^1.110.1" | ||
} | ||
} |
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,91 @@ | ||
import { getSize, getSpace } from "@tamagui/get-token"; | ||
import { | ||
GetProps, | ||
SizeTokens, | ||
View, | ||
Text, | ||
createStyledContext, | ||
styled, | ||
useTheme, | ||
withStaticProperties, | ||
} from "@tamagui/web"; | ||
import { isValidElement, cloneElement, useContext } from "react"; | ||
|
||
export const ButtonContext = createStyledContext({ | ||
size: "$md" as SizeTokens, | ||
}); | ||
|
||
export const ButtonFrame = styled(View, { | ||
name: "Button", | ||
context: ButtonContext, | ||
backgroundColor: "$background", | ||
alignItems: "center", | ||
flexDirection: "row", | ||
|
||
hoverStyle: { | ||
backgroundColor: "$backgroundHover", | ||
}, | ||
|
||
pressStyle: { | ||
backgroundColor: "$backgroundPress", | ||
}, | ||
|
||
variants: { | ||
size: { | ||
"...size": (name, { tokens }) => { | ||
return { | ||
height: tokens.size[name], | ||
borderRadius: tokens.radius[name], | ||
// note the getSpace and getSize helpers will let you shift down/up token sizes | ||
// whereas with gap we just multiply by 0.2 | ||
// this is a stylistic choice, and depends on your design system values | ||
gap: tokens.space[name].val * 0.2, | ||
paddingHorizontal: getSpace(name, { | ||
shift: -1, | ||
}), | ||
}; | ||
}, | ||
}, | ||
} as const, | ||
|
||
defaultVariants: { | ||
size: "$md" as SizeTokens, | ||
}, | ||
}); | ||
|
||
type ButtonProps = GetProps<typeof ButtonFrame>; | ||
|
||
export const ButtonText = styled(Text, { | ||
name: "ButtonText", | ||
context: ButtonContext, | ||
color: "$color", | ||
userSelect: "none", | ||
|
||
variants: { | ||
size: { | ||
"...fontSize": (name, { font }) => ({ | ||
fontSize: font?.size[name], | ||
}), | ||
}, | ||
} as const, | ||
}); | ||
|
||
const ButtonIcon = (props: { children: any }) => { | ||
const { size } = useContext(ButtonContext.context); | ||
const smaller = getSize(size, { | ||
shift: -2, | ||
}); | ||
const theme = useTheme(); | ||
return isValidElement(props.children) | ||
? cloneElement(props.children, { | ||
size: smaller.val * 0.5, | ||
color: theme?.color?.get(), | ||
}) | ||
: null; | ||
}; | ||
|
||
export const Button = withStaticProperties(ButtonFrame, { | ||
Props: ButtonContext.Provider, | ||
Text: ButtonText, | ||
Icon: ButtonIcon, | ||
}); |
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 * from "./Button"; |
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,7 @@ | ||
import { config } from "@helixbridge/tamagui-config"; | ||
|
||
export type Conf = typeof config; | ||
|
||
declare module "tamagui" { | ||
interface TamaguiCustomConfig extends Conf {} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.