Starter Packs (#4332)
Co-authored-by: Dan Abramov <dan.abramov@gmail.com> Co-authored-by: Paul Frazee <pfrazee@gmail.com> Co-authored-by: Eric Bailey <git@esb.lol> Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
parent
35f64535cb
commit
f089f45781
115 changed files with 6336 additions and 237 deletions
5
src/components/icons/QrCode.tsx
Normal file
5
src/components/icons/QrCode.tsx
Normal file
|
@ -0,0 +1,5 @@
|
|||
import {createSinglePathSVG} from './TEMPLATE'
|
||||
|
||||
export const QrCode_Stroke2_Corner0_Rounded = createSinglePathSVG({
|
||||
path: 'M3 5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm6 0H5v4h4V5ZM3 15a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4Zm6 0H5v4h4v-4ZM13 5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V5Zm6 0h-4v4h4V5ZM14 13a1 1 0 0 1 1 1v1h1a1 1 0 1 1 0 2h-2a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1Zm3 1a1 1 0 0 1 1-1h2a1 1 0 1 1 0 2h-2a1 1 0 0 1-1-1Zm0 4a1 1 0 0 1 1-1h2a1 1 0 1 1 0 2h-1v1a1 1 0 1 1-2 0v-2Z',
|
||||
})
|
8
src/components/icons/StarterPack.tsx
Normal file
8
src/components/icons/StarterPack.tsx
Normal file
|
@ -0,0 +1,8 @@
|
|||
import {createMultiPathSVG} from './TEMPLATE'
|
||||
|
||||
export const StarterPack = createMultiPathSVG({
|
||||
paths: [
|
||||
'M11.26 5.227 5.02 6.899c-.734.197-1.17.95-.973 1.685l1.672 6.24c.197.734.951 1.17 1.685.973l6.24-1.672c.734-.197 1.17-.951.973-1.685L12.945 6.2a1.375 1.375 0 0 0-1.685-.973Zm-6.566.459a2.632 2.632 0 0 0-1.86 3.223l1.672 6.24a2.632 2.632 0 0 0 3.223 1.861l6.24-1.672a2.631 2.631 0 0 0 1.861-3.223l-1.672-6.24a2.632 2.632 0 0 0-3.223-1.861l-6.24 1.672Z',
|
||||
'M15.138 18.411a4.606 4.606 0 1 0 0-9.211 4.606 4.606 0 0 0 0 9.211Zm0 1.257a5.862 5.862 0 1 0 0-11.724 5.862 5.862 0 0 0 0 11.724Z',
|
||||
],
|
||||
})
|
|
@ -30,7 +30,7 @@ export const IconTemplate_Stroke2_Corner0_Rounded = React.forwardRef(
|
|||
|
||||
export function createSinglePathSVG({path}: {path: string}) {
|
||||
return React.forwardRef<Svg, Props>(function LogoImpl(props, ref) {
|
||||
const {fill, size, style, ...rest} = useCommonSVGProps(props)
|
||||
const {fill, size, style, gradient, ...rest} = useCommonSVGProps(props)
|
||||
|
||||
return (
|
||||
<Svg
|
||||
|
@ -41,8 +41,37 @@ export function createSinglePathSVG({path}: {path: string}) {
|
|||
width={size}
|
||||
height={size}
|
||||
style={[style]}>
|
||||
{gradient}
|
||||
<Path fill={fill} fillRule="evenodd" clipRule="evenodd" d={path} />
|
||||
</Svg>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export function createMultiPathSVG({paths}: {paths: string[]}) {
|
||||
return React.forwardRef<Svg, Props>(function LogoImpl(props, ref) {
|
||||
const {fill, size, style, gradient, ...rest} = useCommonSVGProps(props)
|
||||
|
||||
return (
|
||||
<Svg
|
||||
fill="none"
|
||||
{...rest}
|
||||
ref={ref}
|
||||
viewBox="0 0 24 24"
|
||||
width={size}
|
||||
height={size}
|
||||
style={[style]}>
|
||||
{gradient}
|
||||
{paths.map((path, i) => (
|
||||
<Path
|
||||
key={i}
|
||||
fill={fill}
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
d={path}
|
||||
/>
|
||||
))}
|
||||
</Svg>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
import {StyleSheet, TextProps} from 'react-native'
|
||||
import type {PathProps, SvgProps} from 'react-native-svg'
|
||||
|
||||
import {tokens} from '#/alf'
|
||||
|
||||
export type Props = {
|
||||
fill?: PathProps['fill']
|
||||
style?: TextProps['style']
|
||||
size?: keyof typeof sizes
|
||||
} & Omit<SvgProps, 'style' | 'size'>
|
||||
|
||||
export const sizes = {
|
||||
xs: 12,
|
||||
sm: 16,
|
||||
md: 20,
|
||||
lg: 24,
|
||||
xl: 28,
|
||||
}
|
||||
|
||||
export function useCommonSVGProps(props: Props) {
|
||||
const {fill, size, ...rest} = props
|
||||
const style = StyleSheet.flatten(rest.style)
|
||||
const _fill = fill || style?.color || tokens.color.blue_500
|
||||
const _size = Number(size ? sizes[size] : rest.width || sizes.md)
|
||||
|
||||
return {
|
||||
fill: _fill,
|
||||
size: _size,
|
||||
style,
|
||||
...rest,
|
||||
}
|
||||
}
|
59
src/components/icons/common.tsx
Normal file
59
src/components/icons/common.tsx
Normal file
|
@ -0,0 +1,59 @@
|
|||
import React from 'react'
|
||||
import {StyleSheet, TextProps} from 'react-native'
|
||||
import type {PathProps, SvgProps} from 'react-native-svg'
|
||||
import {Defs, LinearGradient, Stop} from 'react-native-svg'
|
||||
import {nanoid} from 'nanoid/non-secure'
|
||||
|
||||
import {tokens} from '#/alf'
|
||||
|
||||
export type Props = {
|
||||
fill?: PathProps['fill']
|
||||
style?: TextProps['style']
|
||||
size?: keyof typeof sizes
|
||||
gradient?: keyof typeof tokens.gradients
|
||||
} & Omit<SvgProps, 'style' | 'size'>
|
||||
|
||||
export const sizes = {
|
||||
xs: 12,
|
||||
sm: 16,
|
||||
md: 20,
|
||||
lg: 24,
|
||||
xl: 28,
|
||||
}
|
||||
|
||||
export function useCommonSVGProps(props: Props) {
|
||||
const {fill, size, gradient, ...rest} = props
|
||||
const style = StyleSheet.flatten(rest.style)
|
||||
const _size = Number(size ? sizes[size] : rest.width || sizes.md)
|
||||
let _fill = fill || style?.color || tokens.color.blue_500
|
||||
let gradientDef = null
|
||||
|
||||
if (gradient && tokens.gradients[gradient]) {
|
||||
const id = gradient + '_' + nanoid()
|
||||
const config = tokens.gradients[gradient]
|
||||
_fill = `url(#${id})`
|
||||
gradientDef = (
|
||||
<Defs>
|
||||
<LinearGradient
|
||||
id={id}
|
||||
x1="0"
|
||||
y1="0"
|
||||
x2="100%"
|
||||
y2="0"
|
||||
gradientTransform="rotate(45)">
|
||||
{config.values.map(([stop, fill]) => (
|
||||
<Stop key={stop} offset={stop} stopColor={fill} />
|
||||
))}
|
||||
</LinearGradient>
|
||||
</Defs>
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
fill: _fill,
|
||||
size: _size,
|
||||
style,
|
||||
gradient: gradientDef,
|
||||
...rest,
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue