@sakura-ui/sakura-ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +21 -0
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/examples/index.html +13 -0
- package/examples/src/index.tsx +10 -0
- package/package.json +20 -0
- package/packages/config/coverage/clover.xml +12 -0
- package/packages/config/coverage/coverage-final.json +2 -0
- package/packages/config/coverage/lcov-report/base.css +224 -0
- package/packages/config/coverage/lcov-report/block-navigation.js +87 -0
- package/packages/config/coverage/lcov-report/favicon.png +0 -0
- package/packages/config/coverage/lcov-report/index.html +116 -0
- package/packages/config/coverage/lcov-report/index.ts.html +385 -0
- package/packages/config/coverage/lcov-report/prettify.css +1 -0
- package/packages/config/coverage/lcov-report/prettify.js +2 -0
- package/packages/config/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/packages/config/coverage/lcov-report/sorter.js +196 -0
- package/packages/config/coverage/lcov.info +14 -0
- package/packages/config/jest.config.ts +10 -0
- package/packages/config/package.json +50 -0
- package/packages/config/src/index.ts +100 -0
- package/packages/config/tests/index.test.ts +13 -0
- package/packages/config/tsconfig.json +21 -0
- package/packages/config/vite.config.ts +24 -0
- package/packages/react/package.json +59 -0
- package/packages/react/src/components/Button.tsx +72 -0
- package/packages/react/src/components/Card.tsx +22 -0
- package/packages/react/src/components/Code.tsx +19 -0
- package/packages/react/src/components/Heading.tsx +109 -0
- package/packages/react/src/components/IconButton.tsx +71 -0
- package/packages/react/src/components/InfoCard.tsx +36 -0
- package/packages/react/src/components/Link.tsx +73 -0
- package/packages/react/src/components/List.tsx +38 -0
- package/packages/react/src/components/Pre.tsx +22 -0
- package/packages/react/src/components/Radio.tsx +39 -0
- package/packages/react/src/components/RadioGroup.tsx +38 -0
- package/packages/react/src/components/Select.tsx +41 -0
- package/packages/react/src/components/Table.tsx +111 -0
- package/packages/react/src/components/Text.tsx +35 -0
- package/packages/react/src/components/Textarea.tsx +32 -0
- package/packages/react/src/components/index.ts +15 -0
- package/packages/react/src/index.ts +29 -0
- package/packages/react/src/utils/index.ts +1 -0
- package/packages/react/tsconfig.json +27 -0
- package/packages/react/tsconfig.node.json +9 -0
- package/packages/react/vite.config.ts +26 -0
- package/pnpm-workspace.yaml +3 -0
- package/src/components/Button.tsx +72 -0
- package/src/components/Card.tsx +22 -0
- package/src/components/Code.tsx +19 -0
- package/src/components/Heading.tsx +109 -0
- package/src/components/IconButton.tsx +71 -0
- package/src/components/InfoCard.tsx +36 -0
- package/src/components/Link.tsx +73 -0
- package/src/components/List.tsx +38 -0
- package/src/components/Pre.tsx +22 -0
- package/src/components/Radio.tsx +39 -0
- package/src/components/RadioGroup.tsx +38 -0
- package/src/components/Select.tsx +41 -0
- package/src/components/Table.tsx +111 -0
- package/src/components/Text.tsx +35 -0
- package/src/components/Textarea.tsx +32 -0
- package/src/components/index.ts +15 -0
- package/src/configs/index.ts +92 -0
- package/src/index.ts +59 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type UlProps = React.ComponentProps<'ul'>
|
|
5
|
+
|
|
6
|
+
export const Ul = (props: UlProps) => {
|
|
7
|
+
const { className, children, ...newprops } = props
|
|
8
|
+
|
|
9
|
+
const style = `
|
|
10
|
+
list-disc
|
|
11
|
+
list-inside
|
|
12
|
+
-indent-4
|
|
13
|
+
pl-4
|
|
14
|
+
`
|
|
15
|
+
return (
|
|
16
|
+
<ul className={cx(style, className)} {...newprops}>
|
|
17
|
+
{children}
|
|
18
|
+
</ul>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type OlProps = React.ComponentProps<'ol'>
|
|
23
|
+
|
|
24
|
+
export const Ol = (props: OlProps) => {
|
|
25
|
+
const { className, children, ...newprops } = props
|
|
26
|
+
|
|
27
|
+
const style = `
|
|
28
|
+
list-decimal
|
|
29
|
+
list-inside
|
|
30
|
+
-indent-4
|
|
31
|
+
pl-4
|
|
32
|
+
`
|
|
33
|
+
return (
|
|
34
|
+
<ol className={cx(style, className)} {...newprops}>
|
|
35
|
+
{children}
|
|
36
|
+
</ol>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type PreProps = React.ComponentProps<'pre'>
|
|
5
|
+
|
|
6
|
+
export const Pre = (props: PreProps) => {
|
|
7
|
+
const { className, children, ...newProps } = props
|
|
8
|
+
|
|
9
|
+
const style = `
|
|
10
|
+
p-4
|
|
11
|
+
bg-sumi-50
|
|
12
|
+
rounded-lg
|
|
13
|
+
whitespace-pre-wrap
|
|
14
|
+
overflow-y-scroll
|
|
15
|
+
`
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<pre className={cx(style, className)} {...newProps}>
|
|
19
|
+
{children}
|
|
20
|
+
</pre>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type Props = React.ComponentProps<'input'> & {}
|
|
5
|
+
|
|
6
|
+
export const Radio = React.forwardRef<HTMLInputElement, Props>((props, ref) => {
|
|
7
|
+
const { className, children, ...newProps } = props
|
|
8
|
+
|
|
9
|
+
const style = `
|
|
10
|
+
flex
|
|
11
|
+
items-center
|
|
12
|
+
text-sm
|
|
13
|
+
cursor-pointer
|
|
14
|
+
`
|
|
15
|
+
const styleInput = `
|
|
16
|
+
hidden
|
|
17
|
+
peer
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
const styleRadio = `
|
|
21
|
+
inline-block
|
|
22
|
+
bg-clip-content
|
|
23
|
+
w-6 h-6
|
|
24
|
+
mr-2
|
|
25
|
+
p-1
|
|
26
|
+
rounded-full
|
|
27
|
+
border
|
|
28
|
+
border-solid
|
|
29
|
+
border-sumi-900
|
|
30
|
+
peer-checked:bg-sea-600
|
|
31
|
+
`
|
|
32
|
+
return (
|
|
33
|
+
<label htmlFor={newProps.id} className={cx(style, className)}>
|
|
34
|
+
<input className={styleInput} type="radio" {...newProps} ref={ref} />
|
|
35
|
+
<span className={styleRadio}></span>
|
|
36
|
+
{children}
|
|
37
|
+
</label>
|
|
38
|
+
)
|
|
39
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Radio } from './Radio'
|
|
3
|
+
|
|
4
|
+
interface Item {
|
|
5
|
+
label: string
|
|
6
|
+
value: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface RadioGroupProps {
|
|
10
|
+
name: string
|
|
11
|
+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
12
|
+
items: Item[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const RadioGroup = ({ name, items, onChange }: RadioGroupProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
{items.map(({ label, value }, index) => {
|
|
19
|
+
const itemId = name + value
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div key={index}>
|
|
23
|
+
<Radio
|
|
24
|
+
className="mb-6 ml-4"
|
|
25
|
+
id={itemId}
|
|
26
|
+
name={name}
|
|
27
|
+
value={value}
|
|
28
|
+
onChange={onChange}
|
|
29
|
+
defaultChecked={index === 0}
|
|
30
|
+
>
|
|
31
|
+
{label}
|
|
32
|
+
</Radio>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
})}
|
|
36
|
+
</>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type Props = React.ComponentPropsWithoutRef<'select'>
|
|
5
|
+
|
|
6
|
+
export const Select = React.forwardRef<HTMLSelectElement, Props>(
|
|
7
|
+
(props, ref) => {
|
|
8
|
+
const { className, children, ...newProps } = props
|
|
9
|
+
|
|
10
|
+
const style = `
|
|
11
|
+
block
|
|
12
|
+
appearance-none
|
|
13
|
+
w-full
|
|
14
|
+
bg-white-100
|
|
15
|
+
border
|
|
16
|
+
border-solid
|
|
17
|
+
border-sea-600
|
|
18
|
+
py-4 px-4 pr-8
|
|
19
|
+
rounded-[4px]
|
|
20
|
+
focus:outline
|
|
21
|
+
focus:outline-2
|
|
22
|
+
focus:outline-wood-500
|
|
23
|
+
`
|
|
24
|
+
return (
|
|
25
|
+
<div className="inline-block relative">
|
|
26
|
+
<select className={cx(style, props.className)} {...newProps} ref={ref}>
|
|
27
|
+
{props.children}
|
|
28
|
+
</select>
|
|
29
|
+
<div className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2">
|
|
30
|
+
<svg
|
|
31
|
+
className="fill-current h-4 w-4"
|
|
32
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
33
|
+
viewBox="0 0 20 20"
|
|
34
|
+
>
|
|
35
|
+
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
|
|
36
|
+
</svg>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type TableProps = React.ComponentProps<'table'>
|
|
5
|
+
|
|
6
|
+
const styleBorder = `
|
|
7
|
+
border
|
|
8
|
+
border-collapse
|
|
9
|
+
border-sumi-900
|
|
10
|
+
`
|
|
11
|
+
|
|
12
|
+
export const Table = (props: TableProps) => {
|
|
13
|
+
const { className, children, ...newprops } = props
|
|
14
|
+
|
|
15
|
+
// If there is no break-all setting, the table will protrude when using a smartphone
|
|
16
|
+
const style = `
|
|
17
|
+
w-full
|
|
18
|
+
table-auto
|
|
19
|
+
break-all
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<table className={cx(style, styleBorder, className)} {...newprops}>
|
|
24
|
+
{children}
|
|
25
|
+
</table>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type CaptionProps = React.ComponentProps<'caption'>
|
|
30
|
+
|
|
31
|
+
export const Caption = (props: CaptionProps) => {
|
|
32
|
+
const { className, children, ...newprops } = props
|
|
33
|
+
|
|
34
|
+
const style = `text-left`
|
|
35
|
+
return (
|
|
36
|
+
<caption className={cx(style, className)} {...newprops}>
|
|
37
|
+
{children}
|
|
38
|
+
</caption>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type TheadProps = React.ComponentProps<'thead'>
|
|
43
|
+
|
|
44
|
+
export const Thead = (props: TheadProps) => {
|
|
45
|
+
const { className, children, ...newprops } = props
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<thead className={cx(className)} {...newprops}>
|
|
49
|
+
{children}
|
|
50
|
+
</thead>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type TbodyProps = React.ComponentProps<'tbody'>
|
|
55
|
+
|
|
56
|
+
export const Tbody = (props: TbodyProps) => {
|
|
57
|
+
const { className, children, ...newprops } = props
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<tbody className={cx(className)} {...newprops}>
|
|
61
|
+
{children}
|
|
62
|
+
</tbody>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type ThProps = React.ComponentProps<'th'>
|
|
67
|
+
|
|
68
|
+
export const Th = (props: ThProps) => {
|
|
69
|
+
const { className, children, ...newprops } = props
|
|
70
|
+
|
|
71
|
+
const style = `
|
|
72
|
+
p-2
|
|
73
|
+
bg-sumi-100
|
|
74
|
+
text-left
|
|
75
|
+
`
|
|
76
|
+
return (
|
|
77
|
+
<th className={cx(style, styleBorder, className)} {...newprops}>
|
|
78
|
+
{children}
|
|
79
|
+
</th>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type TrProps = React.ComponentProps<'tr'>
|
|
84
|
+
|
|
85
|
+
export const Tr = (props: TrProps) => {
|
|
86
|
+
const { className, children, ...newprops } = props
|
|
87
|
+
|
|
88
|
+
const style = ``
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<tr className={cx(style, styleBorder, className)} {...newprops}>
|
|
92
|
+
{children}
|
|
93
|
+
</tr>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type TdProps = React.ComponentProps<'td'>
|
|
98
|
+
|
|
99
|
+
export const Td = (props: TdProps) => {
|
|
100
|
+
const { className, children, ...newprops } = props
|
|
101
|
+
|
|
102
|
+
const style = `
|
|
103
|
+
p-2
|
|
104
|
+
`
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<td className={cx(style, styleBorder, className)} {...newprops}>
|
|
108
|
+
{children}
|
|
109
|
+
</td>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type TextProps = React.ComponentPropsWithoutRef<'input'>
|
|
5
|
+
|
|
6
|
+
export const Text = React.forwardRef<HTMLInputElement, TextProps>(
|
|
7
|
+
({ ...props }, ref) => {
|
|
8
|
+
const { className, ...newProps } = props
|
|
9
|
+
|
|
10
|
+
const style = `
|
|
11
|
+
p-4
|
|
12
|
+
rounded-[4px]
|
|
13
|
+
border
|
|
14
|
+
border-solid
|
|
15
|
+
border-sumi-900
|
|
16
|
+
focus:outline
|
|
17
|
+
focus:outline-2
|
|
18
|
+
focus:outline-wood-500
|
|
19
|
+
disabled:bg-sumi-500
|
|
20
|
+
disabled:text-white-1000
|
|
21
|
+
disabled:border
|
|
22
|
+
disabled:border-solid
|
|
23
|
+
disabled:border-sumi-500
|
|
24
|
+
`
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<input
|
|
28
|
+
type="text"
|
|
29
|
+
className={cx(style, className)}
|
|
30
|
+
{...newProps}
|
|
31
|
+
ref={ref}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type TextareaProps = React.ComponentPropsWithoutRef<'textarea'>
|
|
5
|
+
|
|
6
|
+
export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
7
|
+
({ ...props }, ref) => {
|
|
8
|
+
const { className, children, ...newProps } = props
|
|
9
|
+
|
|
10
|
+
const style = `
|
|
11
|
+
p-4
|
|
12
|
+
rounded-[12px]
|
|
13
|
+
border
|
|
14
|
+
border-solid
|
|
15
|
+
border-sumi-900
|
|
16
|
+
focus:outline
|
|
17
|
+
focus:outline-2
|
|
18
|
+
focus:outline-wood-500
|
|
19
|
+
disabled:bg-sumi-500
|
|
20
|
+
disabled:text-white-1000
|
|
21
|
+
disabled:border
|
|
22
|
+
disabled:border-solid
|
|
23
|
+
disabled:border-sumi-500
|
|
24
|
+
`
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<textarea className={cx(style, className)} {...newProps} ref={ref}>
|
|
28
|
+
{children}
|
|
29
|
+
</textarea>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { Button } from './Button'
|
|
2
|
+
export { Card } from './Card'
|
|
3
|
+
export { Code } from './Code'
|
|
4
|
+
export { H1, H2, H3, H4, H5, H6 } from './Heading'
|
|
5
|
+
export { IconButton } from './IconButton'
|
|
6
|
+
export { InfoCard } from './InfoCard'
|
|
7
|
+
export { Link } from './Link'
|
|
8
|
+
export { Ol, Ul } from './List'
|
|
9
|
+
export { Pre } from './Pre'
|
|
10
|
+
export { Radio } from './Radio'
|
|
11
|
+
export { RadioGroup } from './RadioGroup'
|
|
12
|
+
export { Select } from './Select'
|
|
13
|
+
export { Table, Caption, Thead, Tbody, Th, Tr, Td } from './Table'
|
|
14
|
+
export { Text } from './Text'
|
|
15
|
+
export { Textarea } from './Textarea'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Button,
|
|
3
|
+
Card,
|
|
4
|
+
Code,
|
|
5
|
+
H1,
|
|
6
|
+
H2,
|
|
7
|
+
H3,
|
|
8
|
+
H4,
|
|
9
|
+
H5,
|
|
10
|
+
H6,
|
|
11
|
+
IconButton,
|
|
12
|
+
InfoCard,
|
|
13
|
+
Link,
|
|
14
|
+
Ol,
|
|
15
|
+
Ul,
|
|
16
|
+
Pre,
|
|
17
|
+
Radio,
|
|
18
|
+
RadioGroup,
|
|
19
|
+
Select,
|
|
20
|
+
Table,
|
|
21
|
+
Caption,
|
|
22
|
+
Thead,
|
|
23
|
+
Tbody,
|
|
24
|
+
Th,
|
|
25
|
+
Tr,
|
|
26
|
+
Td,
|
|
27
|
+
Text,
|
|
28
|
+
Textarea
|
|
29
|
+
} from './components'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const cx = (...classNames: any[]) => classNames.filter(Boolean).join(' ')
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
6
|
+
"allowJs": false,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"esModuleInterop": false,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"module": "ESNext",
|
|
13
|
+
"moduleResolution": "Node",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"declaration": true,
|
|
19
|
+
"declarationMap": true,
|
|
20
|
+
"baseUrl": ".",
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["src/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": ["src"],
|
|
26
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resolve } from 'path'
|
|
2
|
+
import { defineConfig } from 'vite'
|
|
3
|
+
import react from '@vitejs/plugin-react-swc'
|
|
4
|
+
import { peerDependencies } from './package.json'
|
|
5
|
+
|
|
6
|
+
// https://vitejs.dev/config/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [react()],
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
'@': resolve(__dirname, 'src')
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
build: {
|
|
15
|
+
lib: {
|
|
16
|
+
entry: resolve(__dirname, 'src', 'index.ts'),
|
|
17
|
+
formats: ['es', 'cjs'],
|
|
18
|
+
fileName: (ext) => `index.${ext}.js`
|
|
19
|
+
},
|
|
20
|
+
rollupOptions: {
|
|
21
|
+
external: [...Object.keys(peerDependencies)]
|
|
22
|
+
},
|
|
23
|
+
target: 'esnext',
|
|
24
|
+
sourcemap: true
|
|
25
|
+
}
|
|
26
|
+
})
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type ButtonProps = React.ComponentPropsWithoutRef<'button'> & {
|
|
5
|
+
variant?: 'primary' | 'secondary'
|
|
6
|
+
textAlign?: 'left' | 'right' | 'center'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
10
|
+
(props, ref) => {
|
|
11
|
+
// Make sure that there is no problem even if className is specified on the side that uses the component
|
|
12
|
+
const { className, children, textAlign, variant, ...newProps } = props
|
|
13
|
+
|
|
14
|
+
const align = textAlign ?? 'center'
|
|
15
|
+
|
|
16
|
+
const style = `
|
|
17
|
+
inline-block
|
|
18
|
+
p-4
|
|
19
|
+
text-base
|
|
20
|
+
font-bold
|
|
21
|
+
rounded-lg
|
|
22
|
+
text-${align}
|
|
23
|
+
cursor-pointer
|
|
24
|
+
whitespace-nowrap
|
|
25
|
+
`
|
|
26
|
+
|
|
27
|
+
const primary = `
|
|
28
|
+
text-white-1000
|
|
29
|
+
bg-sea-600
|
|
30
|
+
hover:bg-sea-800
|
|
31
|
+
active:bg-sea-800
|
|
32
|
+
focus:outline
|
|
33
|
+
focus:outline-2
|
|
34
|
+
focus:outline-wood-500
|
|
35
|
+
disabled:bg-sumi-500
|
|
36
|
+
disabled:text-white-1000
|
|
37
|
+
disabled:border
|
|
38
|
+
disabled:border-solid
|
|
39
|
+
disabled:border-sumi-500
|
|
40
|
+
`
|
|
41
|
+
const secondary = `
|
|
42
|
+
border
|
|
43
|
+
border-solid
|
|
44
|
+
border-sea-600
|
|
45
|
+
hover:bg-sea-100
|
|
46
|
+
active:bg-sea-100
|
|
47
|
+
focus:outline
|
|
48
|
+
focus:outline-2
|
|
49
|
+
focus:outline-wood-500
|
|
50
|
+
disabled:bg-sumi-500
|
|
51
|
+
disabled:text-white-1000
|
|
52
|
+
disabled:border
|
|
53
|
+
disabled:border-solid
|
|
54
|
+
disabled:border-sumi-500
|
|
55
|
+
`
|
|
56
|
+
|
|
57
|
+
const styles = {
|
|
58
|
+
primary: primary,
|
|
59
|
+
secondary: secondary
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<button
|
|
64
|
+
className={cx(style, styles[variant ?? 'primary'], className)}
|
|
65
|
+
{...newProps}
|
|
66
|
+
ref={ref}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</button>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type Props = React.ComponentProps<'div'>
|
|
5
|
+
|
|
6
|
+
export const Card = (props: Props) => {
|
|
7
|
+
const { className, children, ...newProps } = props
|
|
8
|
+
|
|
9
|
+
const style = `
|
|
10
|
+
bg-sumi-50
|
|
11
|
+
border
|
|
12
|
+
border-solid
|
|
13
|
+
border-sumi-900
|
|
14
|
+
rounded-[12px]
|
|
15
|
+
p-4
|
|
16
|
+
`
|
|
17
|
+
return (
|
|
18
|
+
<div className={cx(style, props.className)} {...newProps}>
|
|
19
|
+
{props.children}
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { cx } from '../utils'
|
|
3
|
+
|
|
4
|
+
export type CodeProps = React.ComponentProps<'code'>
|
|
5
|
+
|
|
6
|
+
export const Code = (props: CodeProps) => {
|
|
7
|
+
const { className, children, ...newProps } = props
|
|
8
|
+
|
|
9
|
+
const style = `
|
|
10
|
+
bg-sumi-50
|
|
11
|
+
font-mono
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<code className={cx(style, className)} {...newProps}>
|
|
16
|
+
{children}
|
|
17
|
+
</code>
|
|
18
|
+
)
|
|
19
|
+
}
|