@sakura-ui/sakura-ui 0.5.1 → 0.5.2

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 (122) hide show
  1. package/package.json +2 -2
  2. package/packages/core/package.json +1 -1
  3. package/packages/core/src/components/Card.tsx +52 -56
  4. package/packages/core/src/components/Code.tsx +6 -6
  5. package/packages/core/src/components/Faq.tsx +30 -26
  6. package/packages/core/src/components/Heading.tsx +50 -48
  7. package/packages/core/src/components/Icon.tsx +34 -34
  8. package/packages/core/src/components/Link.tsx +13 -12
  9. package/packages/core/src/components/LinkCard.tsx +87 -76
  10. package/packages/core/src/components/List.tsx +20 -13
  11. package/packages/core/src/components/OverflowContainer.tsx +9 -9
  12. package/packages/core/src/components/Pre.tsx +9 -9
  13. package/packages/core/src/components/Table.tsx +29 -24
  14. package/packages/core/src/components/index.ts +1 -0
  15. package/packages/core/src/components/styles.ts +42 -0
  16. package/packages/core/src/index.ts +2 -0
  17. package/packages/forms/.turbo/turbo-build.log +2 -2
  18. package/packages/helper/.turbo/turbo-build.log +1 -1
  19. package/packages/helper/node_modules/.bin/vitest +2 -2
  20. package/packages/markdown/.turbo/turbo-build.log +4 -4
  21. package/packages/markdown/README.md +240 -4
  22. package/packages/markdown/dist/index.cjs.js +71 -137
  23. package/packages/markdown/dist/index.es.js +2624 -16739
  24. package/packages/markdown/dist/types/components/Markdown.d.ts +15 -10
  25. package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -1
  26. package/packages/markdown/dist/types/components/index.d.ts +1 -1
  27. package/packages/markdown/dist/types/components/index.d.ts.map +1 -1
  28. package/packages/markdown/dist/types/decorate.d.ts +24 -0
  29. package/packages/markdown/dist/types/decorate.d.ts.map +1 -0
  30. package/packages/markdown/dist/types/index.d.ts +3 -1
  31. package/packages/markdown/dist/types/index.d.ts.map +1 -1
  32. package/packages/markdown/dist/types/marked/attributes.d.ts +31 -0
  33. package/packages/markdown/dist/types/marked/attributes.d.ts.map +1 -0
  34. package/packages/markdown/dist/types/marked/directives/card.d.ts +3 -0
  35. package/packages/markdown/dist/types/marked/directives/card.d.ts.map +1 -0
  36. package/packages/markdown/dist/types/marked/directives/context.d.ts +36 -0
  37. package/packages/markdown/dist/types/marked/directives/context.d.ts.map +1 -0
  38. package/packages/markdown/dist/types/marked/directives/faq.d.ts +11 -0
  39. package/packages/markdown/dist/types/marked/directives/faq.d.ts.map +1 -0
  40. package/packages/markdown/dist/types/marked/directives/grid.d.ts +9 -0
  41. package/packages/markdown/dist/types/marked/directives/grid.d.ts.map +1 -0
  42. package/packages/markdown/dist/types/marked/directives/index.d.ts +8 -0
  43. package/packages/markdown/dist/types/marked/directives/index.d.ts.map +1 -0
  44. package/packages/markdown/dist/types/marked/directives/linkButton.d.ts +6 -0
  45. package/packages/markdown/dist/types/marked/directives/linkButton.d.ts.map +1 -0
  46. package/packages/markdown/dist/types/marked/directives/youtube.d.ts +3 -0
  47. package/packages/markdown/dist/types/marked/directives/youtube.d.ts.map +1 -0
  48. package/packages/markdown/dist/types/marked/html.d.ts +15 -0
  49. package/packages/markdown/dist/types/marked/html.d.ts.map +1 -0
  50. package/packages/markdown/dist/types/marked/index.d.ts +13 -0
  51. package/packages/markdown/dist/types/marked/index.d.ts.map +1 -0
  52. package/packages/markdown/dist/types/marked/registry.d.ts +8 -0
  53. package/packages/markdown/dist/types/marked/registry.d.ts.map +1 -0
  54. package/packages/markdown/dist/types/marked/renderer.d.ts +16 -0
  55. package/packages/markdown/dist/types/marked/renderer.d.ts.map +1 -0
  56. package/packages/markdown/dist/types/marked/tokenizer.d.ts +40 -0
  57. package/packages/markdown/dist/types/marked/tokenizer.d.ts.map +1 -0
  58. package/packages/markdown/dist/types/render.d.ts +22 -0
  59. package/packages/markdown/dist/types/render.d.ts.map +1 -0
  60. package/packages/markdown/dist/types/sanitize.d.ts +11 -0
  61. package/packages/markdown/dist/types/sanitize.d.ts.map +1 -0
  62. package/packages/markdown/node_modules/.bin/marked +55 -0
  63. package/packages/markdown/package.json +6 -19
  64. package/packages/markdown/src/components/Markdown.tsx +44 -346
  65. package/packages/markdown/src/components/index.ts +1 -1
  66. package/packages/markdown/src/decorate.ts +164 -0
  67. package/packages/markdown/src/index.ts +3 -1
  68. package/packages/markdown/src/marked/attributes.ts +88 -0
  69. package/packages/markdown/src/marked/directives/card.ts +77 -0
  70. package/packages/markdown/src/marked/directives/context.ts +39 -0
  71. package/packages/markdown/src/marked/directives/faq.ts +29 -0
  72. package/packages/markdown/src/marked/directives/grid.ts +50 -0
  73. package/packages/markdown/src/marked/directives/index.ts +29 -0
  74. package/packages/markdown/src/marked/directives/linkButton.ts +20 -0
  75. package/packages/markdown/src/marked/directives/youtube.ts +46 -0
  76. package/packages/markdown/src/marked/html.ts +55 -0
  77. package/packages/markdown/src/marked/index.ts +45 -0
  78. package/packages/markdown/src/marked/registry.ts +34 -0
  79. package/packages/markdown/src/marked/renderer.ts +52 -0
  80. package/packages/markdown/src/marked/tokenizer.ts +175 -0
  81. package/packages/markdown/src/render.ts +55 -0
  82. package/packages/markdown/src/sanitize.ts +194 -0
  83. package/packages/markdown/tests/Markdown.test.tsx +122 -0
  84. package/packages/markdown/tests/__snapshots__/Markdown.test.tsx.snap +451 -0
  85. package/packages/markdown/tests/anchors.test.ts +108 -0
  86. package/packages/markdown/tests/fixtures.ts +100 -0
  87. package/packages/markdown/tests/sanitize.test.ts +168 -0
  88. package/packages/markdown/tests/server.test.tsx +51 -0
  89. package/packages/markdown/tests/vitest.setup.ts +4 -0
  90. package/packages/markdown/tsconfig.test.json +11 -0
  91. package/packages/markdown/vite.config.ts +5 -1
  92. package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +2 -2
  93. package/packages/markdown/dist/types/plugins/attr.d.ts +0 -3
  94. package/packages/markdown/dist/types/plugins/attr.d.ts.map +0 -1
  95. package/packages/markdown/dist/types/plugins/card.d.ts +0 -3
  96. package/packages/markdown/dist/types/plugins/card.d.ts.map +0 -1
  97. package/packages/markdown/dist/types/plugins/cell.d.ts +0 -3
  98. package/packages/markdown/dist/types/plugins/cell.d.ts.map +0 -1
  99. package/packages/markdown/dist/types/plugins/faq.d.ts +0 -3
  100. package/packages/markdown/dist/types/plugins/faq.d.ts.map +0 -1
  101. package/packages/markdown/dist/types/plugins/grid.d.ts +0 -3
  102. package/packages/markdown/dist/types/plugins/grid.d.ts.map +0 -1
  103. package/packages/markdown/dist/types/plugins/headings.d.ts +0 -11
  104. package/packages/markdown/dist/types/plugins/headings.d.ts.map +0 -1
  105. package/packages/markdown/dist/types/plugins/helper.d.ts +0 -9
  106. package/packages/markdown/dist/types/plugins/helper.d.ts.map +0 -1
  107. package/packages/markdown/dist/types/plugins/index.d.ts +0 -9
  108. package/packages/markdown/dist/types/plugins/index.d.ts.map +0 -1
  109. package/packages/markdown/dist/types/plugins/linkButton.d.ts +0 -3
  110. package/packages/markdown/dist/types/plugins/linkButton.d.ts.map +0 -1
  111. package/packages/markdown/dist/types/plugins/youtube.d.ts +0 -3
  112. package/packages/markdown/dist/types/plugins/youtube.d.ts.map +0 -1
  113. package/packages/markdown/src/plugins/attr.ts +0 -19
  114. package/packages/markdown/src/plugins/card.ts +0 -71
  115. package/packages/markdown/src/plugins/cell.ts +0 -47
  116. package/packages/markdown/src/plugins/faq.ts +0 -40
  117. package/packages/markdown/src/plugins/grid.ts +0 -54
  118. package/packages/markdown/src/plugins/headings.ts +0 -38
  119. package/packages/markdown/src/plugins/helper.ts +0 -27
  120. package/packages/markdown/src/plugins/index.ts +0 -8
  121. package/packages/markdown/src/plugins/linkButton.ts +0 -26
  122. package/packages/markdown/src/plugins/youtube.ts +0 -49
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sakura-ui/sakura-ui",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "keywords": [],
5
5
  "author": "glassonion1",
6
6
  "homepage": "https://github.com/glassonion1/sakura-ui",
@@ -19,7 +19,7 @@
19
19
  "pnpm": ">=9.15.1"
20
20
  },
21
21
  "dependencies": {
22
- "@sakura-ui/core": "0.5.1",
22
+ "@sakura-ui/core": "0.5.2",
23
23
  "@sakura-ui/helper": "0.0.10",
24
24
  "@sakura-ui/forms": "0.4.3",
25
25
  "@sakura-ui/tailwind-theme-plugin": "0.4.2"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sakura-ui/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "react",
@@ -1,6 +1,16 @@
1
1
  import React from 'react'
2
2
  import { cx } from '@sakura-ui/helper'
3
3
 
4
+ export const cardStyle = `
5
+ border
6
+ border-solid
7
+ border-solid-gray-500
8
+ rounded-2xl
9
+ sm:rounded-3xl
10
+ text-solid-gray-900
11
+ overflow-hidden
12
+ `
13
+
4
14
  export namespace Card {
5
15
  export interface Props<T extends React.ElementType> {
6
16
  as?: T
@@ -12,20 +22,10 @@ export const Card = <T extends React.ElementType = 'div'>(
12
22
  ) => {
13
23
  const { as: Component = 'div', className, children, ...restProps } = props
14
24
 
15
- const style = `
16
- border
17
- border-solid
18
- border-solid-gray-500
19
- rounded-2xl
20
- sm:rounded-3xl
21
- text-solid-gray-900
22
- overflow-hidden
23
- `
24
-
25
25
  // A div cannot carry an accessible name, so no ARIA is set here. See the
26
26
  // Accessible names section of the README before adding any.
27
27
  return (
28
- <Component className={cx(style, className)} {...restProps}>
28
+ <Component className={cx(cardStyle, className)} {...restProps}>
29
29
  {children}
30
30
  </Component>
31
31
  )
@@ -33,6 +33,40 @@ export const Card = <T extends React.ElementType = 'div'>(
33
33
 
34
34
  Card.displayName = 'Card'
35
35
 
36
+ export const cardImgStyle = `
37
+ object-cover
38
+ mb-2
39
+ `
40
+
41
+ /**
42
+ * Resets the browser defaults of the heading and paragraph elements, so that
43
+ * the element CardHeader renders does not change how the card looks.
44
+ */
45
+ export const cardHeaderStyle = `
46
+ m-0
47
+ text-base
48
+ leading-[2rem]
49
+ font-medium
50
+ first:pt-4
51
+ pt-2
52
+ last:pb-4
53
+ px-6
54
+ `
55
+
56
+ export const cardBodyStyle = `
57
+ text-base-sm
58
+ leading-[1.85rem]
59
+ first:pt-4
60
+ pt-2
61
+ last:pb-4
62
+ px-6
63
+ `
64
+
65
+ export const cardFooterPositionStyle = `
66
+ sticky
67
+ top-full
68
+ `
69
+
36
70
  export namespace CardImg {
37
71
  export interface Props extends React.ComponentPropsWithoutRef<'img'> {}
38
72
  }
@@ -40,13 +74,8 @@ export namespace CardImg {
40
74
  export const CardImg = (props: CardImg.Props) => {
41
75
  const { className, ...restProps } = props
42
76
 
43
- const style = `
44
- object-cover
45
- mb-2
46
- `
47
-
48
77
  // biome-ignore lint/a11y/useAltText: things to check on the user side
49
- return <img className={cx(style, className)} {...restProps} />
78
+ return <img className={cx(cardImgStyle, className)} {...restProps} />
50
79
  }
51
80
 
52
81
  CardImg.displayName = 'CardImg'
@@ -76,21 +105,8 @@ export const CardHeader = (props: CardHeader.Props) => {
76
105
  )
77
106
  }
78
107
 
79
- // Reset the browser defaults of the heading and paragraph elements so that the
80
- // rendered element does not change how the card looks.
81
- const style = `
82
- m-0
83
- text-base
84
- leading-[2rem]
85
- font-medium
86
- first:pt-4
87
- pt-2
88
- last:pb-4
89
- px-6
90
- `
91
-
92
108
  return (
93
- <Component className={cx(style, className)} {...restProps}>
109
+ <Component className={cx(cardHeaderStyle, className)} {...restProps}>
94
110
  {children}
95
111
  </Component>
96
112
  )
@@ -105,19 +121,10 @@ export namespace CardBody {
105
121
  export const CardBody = (props: CardBody.Props) => {
106
122
  const { className, children, ...restProps } = props
107
123
 
108
- const style = `
109
- text-base-sm
110
- leading-[1.85rem]
111
- first:pt-4
112
- pt-2
113
- last:pb-4
114
- px-6
115
- `
116
-
117
124
  // No generated id here. Callers that want the body to describe the card pass
118
125
  // their own id and point aria-describedby at it.
119
126
  return (
120
- <div className={cx(style, className)} {...restProps}>
127
+ <div className={cx(cardBodyStyle, className)} {...restProps}>
121
128
  {children}
122
129
  </div>
123
130
  )
@@ -132,22 +139,11 @@ export namespace CardFooter {
132
139
  export const CardFooter = (props: CardFooter.Props) => {
133
140
  const { className, children, ...restProps } = props
134
141
 
135
- const stylePosition = `
136
- sticky
137
- top-full
138
- `
139
-
140
- const style = `
141
- text-base-sm
142
- leading-[1.85rem]
143
- first:pt-4
144
- pt-2
145
- last:pb-4
146
- px-6
147
- `
148
-
149
142
  return (
150
- <div className={cx(stylePosition, style, className)} {...restProps}>
143
+ <div
144
+ className={cx(cardFooterPositionStyle, cardBodyStyle, className)}
145
+ {...restProps}
146
+ >
151
147
  {children}
152
148
  </div>
153
149
  )
@@ -1,6 +1,11 @@
1
1
  import React from 'react'
2
2
  import { cx } from '@sakura-ui/helper'
3
3
 
4
+ export const codeStyle = `
5
+ bg-solid-gray-50
6
+ font-mono
7
+ `
8
+
4
9
  export namespace Code {
5
10
  export interface Props extends React.ComponentPropsWithoutRef<'code'> {}
6
11
  }
@@ -8,13 +13,8 @@ export namespace Code {
8
13
  export const Code = (props: Code.Props) => {
9
14
  const { className, children, ...restProps } = props
10
15
 
11
- const style = `
12
- bg-solid-gray-50
13
- font-mono
14
- `
15
-
16
16
  return (
17
- <code className={cx(style, className)} {...restProps}>
17
+ <code className={cx(codeStyle, className)} {...restProps}>
18
18
  {children}
19
19
  </code>
20
20
  )
@@ -1,27 +1,43 @@
1
1
  import React from 'react'
2
2
  import { cx } from '@sakura-ui/helper'
3
3
 
4
- export namespace Faq {
5
- export interface Props extends React.ComponentPropsWithoutRef<'dl'> {}
6
- }
7
-
8
- const headingStyle = `
4
+ /** The size of the Q and A markers, matching a medium heading. */
5
+ export const faqMarkerStyle = `
9
6
  text-h-med-m
10
7
  sm:text-h-med
11
8
  `
12
9
 
10
+ export const faqStyle = `
11
+ flex
12
+ flex-col
13
+ gap-8
14
+ `
15
+
16
+ export const questionStyle = `
17
+ flex
18
+ flex-row
19
+ gap-8
20
+ mt-8
21
+ `
22
+
23
+ export const answerStyle = `
24
+ flex
25
+ flex-row
26
+ items-start
27
+ gap-8
28
+ `
29
+
30
+ export namespace Faq {
31
+ export interface Props extends React.ComponentPropsWithoutRef<'dl'> {}
32
+ }
33
+
13
34
  export const Faq = (props: Faq.Props) => {
14
35
  const { className, children, ...restProps } = props
15
36
 
16
- const style = `
17
- flex
18
- flex-col
19
- gap-8
20
- `
21
37
  // No schema.org FAQPage markup here. Google discontinued the FAQ rich result
22
38
  // in May 2026, so it is not implemented.
23
39
  return (
24
- <dl className={cx(style, className)} {...restProps}>
40
+ <dl className={cx(faqStyle, className)} {...restProps}>
25
41
  {children}
26
42
  </dl>
27
43
  )
@@ -34,14 +50,8 @@ export namespace Question {
34
50
  export const Question = (props: Question.Props) => {
35
51
  const { className, children, ...restProps } = props
36
52
 
37
- const style = `
38
- flex
39
- flex-row
40
- gap-8
41
- mt-8
42
- `
43
53
  return (
44
- <dt className={cx(style, headingStyle, className)} {...restProps}>
54
+ <dt className={cx(questionStyle, faqMarkerStyle, className)} {...restProps}>
45
55
  <span aria-hidden="true">Q</span>
46
56
  <span>{children}</span>
47
57
  </dt>
@@ -55,15 +65,9 @@ export namespace Answer {
55
65
  export const Answer = (props: Answer.Props) => {
56
66
  const { className, children, ...restProps } = props
57
67
 
58
- const style = `
59
- flex
60
- flex-row
61
- items-start
62
- gap-8
63
- `
64
68
  return (
65
- <dd className={cx(style, className)} {...restProps}>
66
- <span className={cx(headingStyle, '!leading-none')} aria-hidden="true">
69
+ <dd className={cx(answerStyle, className)} {...restProps}>
70
+ <span className={cx(faqMarkerStyle, '!leading-none')} aria-hidden="true">
67
71
  A
68
72
  </span>
69
73
  <span>{children}</span>
@@ -1,6 +1,50 @@
1
1
  import React from 'react'
2
2
  import { cx } from '@sakura-ui/helper'
3
3
 
4
+ /**
5
+ * The classes each heading level carries. Exported so that anything rendering
6
+ * headings without React — @sakura-ui/markdown builds HTML strings — reads the
7
+ * same values instead of keeping a copy that drifts.
8
+ */
9
+ export const headingStyle = {
10
+ h1: `
11
+ text-h-lg-m
12
+ sm:text-h-lg
13
+ pt-[2rem]
14
+ sm:pt-[6.5rem]
15
+ `,
16
+ h2: `
17
+ text-h-med-m
18
+ sm:text-h-med
19
+ pt-[4rem]
20
+ sm:pt-[4.5rem]
21
+ `,
22
+ h3: `
23
+ text-h-sm-m
24
+ sm:text-h-sm
25
+ pt-[4rem]
26
+ sm:pt-[4.5rem]
27
+ `,
28
+ h4: `
29
+ text-h-xs-m
30
+ sm:text-h-xs
31
+ pt-[3.5rem]
32
+ sm:pt-[4.5rem]
33
+ `,
34
+ h5: `
35
+ text-h-xxs-m
36
+ sm:text-h-xxs
37
+ pt-[3rem]
38
+ sm:pt-[4rem]
39
+ `,
40
+ h6: `
41
+ text-h-xxs-m
42
+ sm:text-h-xxs
43
+ pt-[2.5rem]
44
+ sm:pt-[3.5rem]
45
+ `
46
+ } as const
47
+
4
48
  export namespace H1 {
5
49
  export interface Props extends React.ComponentPropsWithoutRef<'h1'> {}
6
50
  }
@@ -8,15 +52,8 @@ export namespace H1 {
8
52
  export const H1 = (props: H1.Props) => {
9
53
  const { className, children, ...restProps } = props
10
54
 
11
- const style = `
12
- text-h-lg-m
13
- sm:text-h-lg
14
- pt-[2rem]
15
- sm:pt-[6.5rem]
16
- `
17
-
18
55
  return (
19
- <h1 className={cx(style, className)} {...restProps}>
56
+ <h1 className={cx(headingStyle.h1, className)} {...restProps}>
20
57
  {children}
21
58
  </h1>
22
59
  )
@@ -29,15 +66,8 @@ export namespace H2 {
29
66
  export const H2 = (props: H2.Props) => {
30
67
  const { className, children, ...restProps } = props
31
68
 
32
- const style = `
33
- text-h-med-m
34
- sm:text-h-med
35
- pt-[4rem]
36
- sm:pt-[4.5rem]
37
- `
38
-
39
69
  return (
40
- <h2 className={cx(style, className)} {...restProps}>
70
+ <h2 className={cx(headingStyle.h2, className)} {...restProps}>
41
71
  {children}
42
72
  </h2>
43
73
  )
@@ -50,15 +80,8 @@ export namespace H3 {
50
80
  export const H3 = (props: H3.Props) => {
51
81
  const { className, children, ...restProps } = props
52
82
 
53
- const style = `
54
- text-h-sm-m
55
- sm:text-h-sm
56
- pt-[4rem]
57
- sm:pt-[4.5rem]
58
- `
59
-
60
83
  return (
61
- <h3 className={cx(style, className)} {...restProps}>
84
+ <h3 className={cx(headingStyle.h3, className)} {...restProps}>
62
85
  {children}
63
86
  </h3>
64
87
  )
@@ -71,15 +94,8 @@ export namespace H4 {
71
94
  export const H4 = (props: H4.Props) => {
72
95
  const { className, children, ...restProps } = props
73
96
 
74
- const style = `
75
- text-h-xs-m
76
- sm:text-h-xs
77
- pt-[3.5rem]
78
- sm:pt-[4.5rem]
79
- `
80
-
81
97
  return (
82
- <h4 className={cx(style, className)} {...restProps}>
98
+ <h4 className={cx(headingStyle.h4, className)} {...restProps}>
83
99
  {children}
84
100
  </h4>
85
101
  )
@@ -92,15 +108,8 @@ export namespace H5 {
92
108
  export const H5 = (props: H5.Props) => {
93
109
  const { className, children, ...restProps } = props
94
110
 
95
- const style = `
96
- text-h-xxs-m
97
- sm:text-h-xxs
98
- pt-[3rem]
99
- sm:pt-[4rem]
100
- `
101
-
102
111
  return (
103
- <h5 className={cx(style, className)} {...restProps}>
112
+ <h5 className={cx(headingStyle.h5, className)} {...restProps}>
104
113
  {children}
105
114
  </h5>
106
115
  )
@@ -113,15 +122,8 @@ export namespace H6 {
113
122
  export const H6 = (props: H6.Props) => {
114
123
  const { className, children, ...restProps } = props
115
124
 
116
- const style = `
117
- text-h-xxs-m
118
- sm:text-h-xxs
119
- pt-[2.5rem]
120
- sm:pt-[3.5rem]
121
- `
122
-
123
125
  return (
124
- <h6 className={cx(style, className)} {...restProps}>
126
+ <h6 className={cx(headingStyle.h6, className)} {...restProps}>
125
127
  {children}
126
128
  </h6>
127
129
  )
@@ -8,43 +8,43 @@ export namespace Icon {
8
8
  }
9
9
  }
10
10
 
11
- export const Icon = React.forwardRef<HTMLElement, Icon.Props>((props, ref) => {
12
- const { className, altText = '', opticalSize = 24, children, ...rest } = props
13
-
14
- const size = {
15
- 16: '!text-[16px]',
16
- 20: '!text-[20px]',
17
- 24: '!text-[24px]',
18
- 40: '!text-[40px]',
19
- 44: '!text-[44px]',
20
- 48: '!text-[48px]'
21
- }
11
+ export const iconSizeStyle = {
12
+ 16: '!text-[16px]',
13
+ 20: '!text-[20px]',
14
+ 24: '!text-[24px]',
15
+ 40: '!text-[40px]',
16
+ 44: '!text-[44px]',
17
+ 48: '!text-[48px]'
18
+ } as const
22
19
 
23
- const fontSize = size[opticalSize]
20
+ // @see: https://developers.google.com/fonts/docs/material_symbols
21
+ //.material-symbols-outlined {
22
+ // font-family: 'Material Symbols Outlined';
23
+ // font-weight: normal;
24
+ // font-style: normal;
25
+ // font-size: 24px; /* Preferred icon size */
26
+ // display: inline-block;
27
+ // line-height: 1;
28
+ // text-transform: none;
29
+ // letter-spacing: normal;
30
+ // word-wrap: normal;
31
+ // white-space: nowrap;
32
+ // direction: ltr;
33
+ //}
34
+ export const iconStyle = `
35
+ font-icon
36
+ font-light
37
+ inline-block
38
+ leading-none
39
+ align-middle
40
+ whitespace-nowrap
41
+ `
24
42
 
25
- // @see: https://developers.google.com/fonts/docs/material_symbols
26
- //.material-symbols-outlined {
27
- // font-family: 'Material Symbols Outlined';
28
- // font-weight: normal;
29
- // font-style: normal;
30
- // font-size: 24px; /* Preferred icon size */
31
- // display: inline-block;
32
- // line-height: 1;
33
- // text-transform: none;
34
- // letter-spacing: normal;
35
- // word-wrap: normal;
36
- // white-space: nowrap;
37
- // direction: ltr;
38
- //}
43
+ export const Icon = React.forwardRef<HTMLElement, Icon.Props>((props, ref) => {
44
+ const { className, altText = '', opticalSize = 24, children, ...rest } = props
39
45
 
40
- const style = `
41
- font-icon
42
- font-light
43
- inline-block
44
- leading-none
45
- align-middle
46
- whitespace-nowrap
47
- `
46
+ const fontSize = iconSizeStyle[opticalSize]
47
+ const style = iconStyle
48
48
 
49
49
  return (
50
50
  <>
@@ -2,6 +2,18 @@ import React from 'react'
2
2
  import { cx, Style } from '@sakura-ui/helper'
3
3
  import { Icon } from './Icon'
4
4
 
5
+ // Make lines break at each word
6
+ export const linkStyle = `
7
+ cursor-pointer
8
+ text-blue-1000
9
+ active:text-orange-700
10
+ visited:text-magenta-900
11
+ ${Style.focusRoundedWithBg}
12
+ ${Style.underline}
13
+ disabled:border-solid-gray-500
14
+ [overflow-wrap:anywhere]
15
+ `
16
+
5
17
  export namespace Link {
6
18
  export interface Props<T extends React.ElementType> {
7
19
  as?: T
@@ -12,18 +24,7 @@ export const Link = <T extends React.ElementType = 'a'>(
12
24
  props: Link.Props<T> & Omit<React.ComponentProps<T>, keyof Link.Props<T>>
13
25
  ) => {
14
26
  const { as: Component = 'a', className, children, ...restProps } = props
15
-
16
- // Make lines break at each word
17
- const style = `
18
- cursor-pointer
19
- text-blue-1000
20
- active:text-orange-700
21
- visited:text-magenta-900
22
- ${Style.focusRoundedWithBg}
23
- ${Style.underline}
24
- disabled:border-solid-gray-500
25
- [overflow-wrap:anywhere]
26
- `
27
+ const style = linkStyle
27
28
 
28
29
  if (restProps.href?.startsWith('http') || restProps.target === '_blank') {
29
30
  return (