@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.
Files changed (66) hide show
  1. package/.prettierrc +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +37 -0
  4. package/examples/index.html +13 -0
  5. package/examples/src/index.tsx +10 -0
  6. package/package.json +20 -0
  7. package/packages/config/coverage/clover.xml +12 -0
  8. package/packages/config/coverage/coverage-final.json +2 -0
  9. package/packages/config/coverage/lcov-report/base.css +224 -0
  10. package/packages/config/coverage/lcov-report/block-navigation.js +87 -0
  11. package/packages/config/coverage/lcov-report/favicon.png +0 -0
  12. package/packages/config/coverage/lcov-report/index.html +116 -0
  13. package/packages/config/coverage/lcov-report/index.ts.html +385 -0
  14. package/packages/config/coverage/lcov-report/prettify.css +1 -0
  15. package/packages/config/coverage/lcov-report/prettify.js +2 -0
  16. package/packages/config/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/packages/config/coverage/lcov-report/sorter.js +196 -0
  18. package/packages/config/coverage/lcov.info +14 -0
  19. package/packages/config/jest.config.ts +10 -0
  20. package/packages/config/package.json +50 -0
  21. package/packages/config/src/index.ts +100 -0
  22. package/packages/config/tests/index.test.ts +13 -0
  23. package/packages/config/tsconfig.json +21 -0
  24. package/packages/config/vite.config.ts +24 -0
  25. package/packages/react/package.json +59 -0
  26. package/packages/react/src/components/Button.tsx +72 -0
  27. package/packages/react/src/components/Card.tsx +22 -0
  28. package/packages/react/src/components/Code.tsx +19 -0
  29. package/packages/react/src/components/Heading.tsx +109 -0
  30. package/packages/react/src/components/IconButton.tsx +71 -0
  31. package/packages/react/src/components/InfoCard.tsx +36 -0
  32. package/packages/react/src/components/Link.tsx +73 -0
  33. package/packages/react/src/components/List.tsx +38 -0
  34. package/packages/react/src/components/Pre.tsx +22 -0
  35. package/packages/react/src/components/Radio.tsx +39 -0
  36. package/packages/react/src/components/RadioGroup.tsx +38 -0
  37. package/packages/react/src/components/Select.tsx +41 -0
  38. package/packages/react/src/components/Table.tsx +111 -0
  39. package/packages/react/src/components/Text.tsx +35 -0
  40. package/packages/react/src/components/Textarea.tsx +32 -0
  41. package/packages/react/src/components/index.ts +15 -0
  42. package/packages/react/src/index.ts +29 -0
  43. package/packages/react/src/utils/index.ts +1 -0
  44. package/packages/react/tsconfig.json +27 -0
  45. package/packages/react/tsconfig.node.json +9 -0
  46. package/packages/react/vite.config.ts +26 -0
  47. package/pnpm-workspace.yaml +3 -0
  48. package/src/components/Button.tsx +72 -0
  49. package/src/components/Card.tsx +22 -0
  50. package/src/components/Code.tsx +19 -0
  51. package/src/components/Heading.tsx +109 -0
  52. package/src/components/IconButton.tsx +71 -0
  53. package/src/components/InfoCard.tsx +36 -0
  54. package/src/components/Link.tsx +73 -0
  55. package/src/components/List.tsx +38 -0
  56. package/src/components/Pre.tsx +22 -0
  57. package/src/components/Radio.tsx +39 -0
  58. package/src/components/RadioGroup.tsx +38 -0
  59. package/src/components/Select.tsx +41 -0
  60. package/src/components/Table.tsx +111 -0
  61. package/src/components/Text.tsx +35 -0
  62. package/src/components/Textarea.tsx +32 -0
  63. package/src/components/index.ts +15 -0
  64. package/src/configs/index.ts +92 -0
  65. package/src/index.ts +59 -0
  66. package/src/utils/index.ts +1 -0
@@ -0,0 +1,109 @@
1
+ import React from 'react'
2
+ import { cx } from '../utils'
3
+
4
+ export type HeadingProps = React.ComponentProps<'h1'>
5
+
6
+ const common = `
7
+ font-bold
8
+ `
9
+
10
+ export const H1 = (props: HeadingProps) => {
11
+ const { className, children, ...newProps } = props
12
+
13
+ const style = `
14
+ text-h1
15
+ mt-16
16
+ mb-6
17
+ `
18
+
19
+ return (
20
+ <h1 className={cx(common, style, props.className)} {...newProps}>
21
+ {props.children}
22
+ </h1>
23
+ )
24
+ }
25
+
26
+ export const H2 = (props: HeadingProps) => {
27
+ // コンポーネントを使う側でclassNameを指定しても問題ないようにする
28
+ const { className, children, ...newProps } = props
29
+
30
+ const style = `
31
+ text-h2
32
+ mt-16
33
+ mb-6
34
+ `
35
+
36
+ return (
37
+ <h2 className={cx(common, style, props.className)} {...newProps}>
38
+ {props.children}
39
+ </h2>
40
+ )
41
+ }
42
+
43
+ export const H3 = (props: HeadingProps) => {
44
+ // コンポーネントを使う側でclassNameを指定しても問題ないようにする
45
+ const { className, children, ...newProps } = props
46
+
47
+ const style = `
48
+ text-h3
49
+ mt-10
50
+ mb-6
51
+ `
52
+
53
+ return (
54
+ <h3 className={cx(common, style, props.className)} {...newProps}>
55
+ {props.children}
56
+ </h3>
57
+ )
58
+ }
59
+
60
+ export const H4 = (props: HeadingProps) => {
61
+ // コンポーネントを使う側でclassNameを指定しても問題ないようにする
62
+ const { className, children, ...newProps } = props
63
+
64
+ const style = `
65
+ text-h4
66
+ mt-10
67
+ mb-4
68
+ `
69
+
70
+ return (
71
+ <h4 className={cx(common, style, props.className)} {...newProps}>
72
+ {props.children}
73
+ </h4>
74
+ )
75
+ }
76
+
77
+ export const H5 = (props: HeadingProps) => {
78
+ // コンポーネントを使う側でclassNameを指定しても問題ないようにする
79
+ const { className, children, ...newProps } = props
80
+
81
+ const style = `
82
+ text-h5
83
+ mt-10
84
+ mb-4
85
+ `
86
+
87
+ return (
88
+ <h5 className={cx(common, style, props.className)} {...newProps}>
89
+ {props.children}
90
+ </h5>
91
+ )
92
+ }
93
+
94
+ export const H6 = (props: HeadingProps) => {
95
+ // コンポーネントを使う側でclassNameを指定しても問題ないようにする
96
+ const { className, children, ...newProps } = props
97
+
98
+ const style = `
99
+ text-h6
100
+ mt-6
101
+ mb-4
102
+ `
103
+
104
+ return (
105
+ <h6 className={cx(common, style, props.className)} {...newProps}>
106
+ {props.children}
107
+ </h6>
108
+ )
109
+ }
@@ -0,0 +1,71 @@
1
+ import React from 'react'
2
+ import { cx } from '../utils'
3
+
4
+ export type IconButtonProps = React.ComponentProps<'button'> & {
5
+ variant?: 'primary' | 'secondary'
6
+ icon: string
7
+ }
8
+
9
+ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
10
+ (props, ref) => {
11
+ const { className, children, icon, variant, ...newProps } = props
12
+
13
+ const align = 'center'
14
+
15
+ const style = `
16
+ inline-block
17
+ p-4
18
+ text-base
19
+ font-bold
20
+ rounded-lg
21
+ text-${align}
22
+ cursor-pointer
23
+ `
24
+
25
+ const primary = `
26
+ text-white-1000
27
+ bg-sea-600
28
+ hover:bg-sea-800
29
+ active:bg-sea-800
30
+ focus:outline
31
+ focus:outline-2
32
+ focus:outline-wood-500
33
+ disabled:bg-sumi-500
34
+ disabled:text-white-1000
35
+ disabled:border
36
+ disabled:border-solid
37
+ disabled:border-sumi-500
38
+ `
39
+ const secondary = `
40
+ border
41
+ border-solid
42
+ border-sea-600
43
+ hover:bg-sea-100
44
+ active:bg-sea-100
45
+ focus:outline
46
+ focus:outline-2
47
+ focus:outline-wood-500
48
+ disabled:bg-sumi-500
49
+ disabled:text-white-1000
50
+ disabled:border
51
+ disabled:border-solid
52
+ disabled:border-sumi-500
53
+ `
54
+
55
+ const styles = {
56
+ primary: primary,
57
+ secondary: secondary
58
+ }
59
+
60
+ return (
61
+ <button
62
+ className={cx(style, styles[variant ?? 'primary'], className)}
63
+ {...newProps}
64
+ ref={ref}
65
+ >
66
+ <img src={`/icons/${props.icon}.svg`} alt={props.icon} width="24" />
67
+ {children}
68
+ </button>
69
+ )
70
+ }
71
+ )
@@ -0,0 +1,36 @@
1
+ import React from 'react'
2
+ import { cx } from '../utils'
3
+
4
+ export type Props = React.ComponentProps<'div'> & {
5
+ title?: string
6
+ }
7
+
8
+ export const InfoCard = (props: Props) => {
9
+ const { className, children, ...newProps } = props
10
+
11
+ const style = `
12
+ bg-sumi-50
13
+ border-sumi-900
14
+ border
15
+ border-solid
16
+ rounded-[12px]
17
+ `
18
+
19
+ const topStyle = `
20
+ p-4
21
+ text-h5
22
+ font-bold
23
+ `
24
+
25
+ const bottmStyle = `
26
+ px-4
27
+ pb-4
28
+ `
29
+
30
+ return (
31
+ <div className={cx(style, props.className)} {...newProps}>
32
+ <h2 className={topStyle}>{props.title}</h2>
33
+ <p className={bottmStyle}>{props.children}</p>
34
+ </div>
35
+ )
36
+ }
@@ -0,0 +1,73 @@
1
+ import React from 'react'
2
+ import { cx } from '../utils'
3
+
4
+ export type LinkProps = React.ComponentProps<'a'>
5
+
6
+ const getFileType = (url: string) => {
7
+ const converted = url.toLowerCase()
8
+
9
+ if (converted.endsWith('.pdf')) {
10
+ return 'PDF'
11
+ }
12
+ if (converted.endsWith('.doc') || converted.endsWith('.docx')) {
13
+ return 'Word'
14
+ }
15
+ if (converted.endsWith('.xls') || converted.endsWith('.xlsx')) {
16
+ return 'Excel'
17
+ }
18
+ if (converted.endsWith('.csv')) {
19
+ return 'CSV'
20
+ }
21
+ if (converted.endsWith('.json')) {
22
+ return 'JSON'
23
+ }
24
+ if (converted.endsWith('.ndjson')) {
25
+ return 'NDJSON'
26
+ }
27
+ if (converted.includes('youtu.be')) {
28
+ return 'YouTube'
29
+ }
30
+ return null
31
+ }
32
+
33
+ export const Link = (props: LinkProps) => {
34
+ const { className, children, ...newProps } = props
35
+ const href = props.href ?? ''
36
+ const fileType = getFileType(href)
37
+
38
+ const style = `
39
+ rounded-sm
40
+ cursor-pointer
41
+ text-sea-600
42
+ underline
43
+ underline-offset-[0.1em]
44
+ hover:text-sea-800
45
+ active:text-sea-800
46
+ visited:text-sea-900
47
+ focus:outline
48
+ focus:outline-2
49
+ focus:outline-wood-500
50
+ disabled:border-sumi-500
51
+ `
52
+
53
+ if (href.startsWith('http')) {
54
+ return (
55
+ <a
56
+ className={cx(style, props.className)}
57
+ href={href}
58
+ target="_blank"
59
+ rel="noopener noreferrer"
60
+ {...newProps}
61
+ >
62
+ {props.children}
63
+ {fileType ? `(${fileType})` : null}
64
+ </a>
65
+ )
66
+ }
67
+ return (
68
+ <a className={cx(style, props.className)} href={href} {...newProps}>
69
+ {props.children}
70
+ {fileType ? `(${fileType})` : null}
71
+ </a>
72
+ )
73
+ }
@@ -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'