@sakura-ui/sakura-ui 0.1.14 → 0.1.17
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/package.json +1 -1
- package/packages/config/package.json +2 -1
- package/packages/config/src/index.ts +8 -0
- package/packages/core/package.json +2 -1
- package/packages/core/src/components/Button.tsx +23 -56
- package/packages/core/src/components/Card.tsx +14 -14
- package/packages/core/src/components/Code.tsx +1 -1
- package/packages/core/src/components/Faq.tsx +5 -5
- package/packages/core/src/components/Heading.tsx +1 -1
- package/packages/core/src/components/Icon.tsx +2 -6
- package/packages/core/src/components/IconButton.tsx +47 -76
- package/packages/core/src/components/InfoCard.tsx +1 -1
- package/packages/core/src/components/Link.tsx +53 -44
- package/packages/core/src/components/List.tsx +1 -1
- package/packages/core/src/components/Pre.tsx +1 -1
- package/packages/core/src/components/Table.tsx +1 -1
- package/packages/core/src/components/buttonStyle.ts +83 -0
- package/packages/core/src/components/index.ts +24 -7
- package/packages/core/src/index.ts +26 -0
- package/packages/core/src/libs/forward-ref.ts +41 -0
- package/packages/core/src/types/component.ts +82 -0
- package/packages/forms/dist/components/Checkbox.d.ts.map +1 -1
- package/packages/forms/dist/components/Checkbox.js +26 -23
- package/packages/forms/dist/components/Checkbox.js.map +1 -1
- package/packages/forms/dist/components/FileInput.d.ts +5 -0
- package/packages/forms/dist/components/FileInput.d.ts.map +1 -0
- package/packages/forms/dist/components/FileInput.js +51 -0
- package/packages/forms/dist/components/FileInput.js.map +1 -0
- package/packages/forms/dist/components/Input.d.ts.map +1 -1
- package/packages/forms/dist/components/Input.js +1 -0
- package/packages/forms/dist/components/Input.js.map +1 -1
- package/packages/forms/dist/components/LabelControl.d.ts.map +1 -1
- package/packages/forms/dist/components/LabelControl.js +7 -1
- package/packages/forms/dist/components/LabelControl.js.map +1 -1
- package/packages/forms/dist/components/Radio.d.ts.map +1 -1
- package/packages/forms/dist/components/Radio.js +25 -23
- package/packages/forms/dist/components/Radio.js.map +1 -1
- package/packages/forms/dist/components/Select.d.ts.map +1 -1
- package/packages/forms/dist/components/Select.js +1 -0
- package/packages/forms/dist/components/Select.js.map +1 -1
- package/packages/forms/dist/components/Textarea.d.ts.map +1 -1
- package/packages/forms/dist/components/Textarea.js +1 -0
- package/packages/forms/dist/components/Textarea.js.map +1 -1
- package/packages/forms/dist/components/index.d.ts +8 -7
- package/packages/forms/dist/components/index.d.ts.map +1 -1
- package/packages/forms/dist/components/index.js +1 -0
- package/packages/forms/dist/components/index.js.map +1 -1
- package/packages/forms/dist/index.cjs.js +103 -59
- package/packages/forms/dist/index.cjs.js.map +1 -1
- package/packages/forms/dist/index.d.ts +2 -1
- package/packages/forms/dist/index.d.ts.map +1 -1
- package/packages/forms/dist/index.es.js +383 -313
- package/packages/forms/dist/index.es.js.map +1 -1
- package/packages/forms/dist/index.js +1 -1
- package/packages/forms/dist/index.js.map +1 -1
- package/packages/forms/package.json +2 -1
- package/packages/forms/src/components/Checkbox.tsx +26 -23
- package/packages/forms/src/components/FileInput.tsx +77 -0
- package/packages/forms/src/components/Input.tsx +1 -0
- package/packages/forms/src/components/LabelControl.tsx +13 -6
- package/packages/forms/src/components/Radio.tsx +27 -23
- package/packages/forms/src/components/Select.tsx +1 -0
- package/packages/forms/src/components/Textarea.tsx +1 -0
- package/packages/forms/src/components/index.ts +8 -7
- package/packages/forms/src/index.ts +12 -0
- /package/packages/core/src/{utils/class.ts → libs/cx.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sakura-ui/config",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
8
9
|
"require": "./dist/index.cjs.js",
|
|
9
10
|
"import": "./dist/index.es.js"
|
|
10
11
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sakura-ui/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
9
10
|
"require": "./dist/index.cjs.js",
|
|
10
11
|
"import": "./dist/index.es.js"
|
|
11
12
|
}
|
|
@@ -1,70 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { cx } from '../libs/cx'
|
|
2
|
+
import { ComponentWithAs } from '../types/component'
|
|
3
|
+
import { forwardRef } from '../libs/forward-ref'
|
|
4
|
+
import { base, getVariantStyle, getSizeStyle } from './buttonStyle'
|
|
3
5
|
|
|
4
|
-
export interface ButtonProps
|
|
6
|
+
export interface ButtonProps {
|
|
5
7
|
variant?: 'primary' | 'secondary'
|
|
6
|
-
|
|
8
|
+
size?: 'lg' | 'md' | 'sm' | 'xs'
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
export const Button
|
|
11
|
+
export const Button: ComponentWithAs<'button', ButtonProps> = forwardRef(
|
|
10
12
|
(props, ref) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
p-4
|
|
20
|
-
text-button
|
|
21
|
-
text-${align}
|
|
22
|
-
rounded-lg
|
|
23
|
-
cursor-pointer
|
|
24
|
-
whitespace-nowrap
|
|
25
|
-
border
|
|
26
|
-
border-solid
|
|
27
|
-
border-sea-800
|
|
28
|
-
active:enabled:border-sea-800/[.8]
|
|
29
|
-
hover:enabled:border-sea-800/[.85]
|
|
30
|
-
focus:outline
|
|
31
|
-
focus:outline-2
|
|
32
|
-
focus:outline-wood-600
|
|
33
|
-
disabled:border-sumi-500
|
|
34
|
-
disabled:cursor-not-allowed
|
|
35
|
-
`
|
|
36
|
-
|
|
37
|
-
const primary = `
|
|
38
|
-
text-white-1000
|
|
39
|
-
bg-sea-800
|
|
40
|
-
active:enabled:bg-sea-800/[.8]
|
|
41
|
-
hover:enabled:bg-sea-800/[.85]
|
|
42
|
-
disabled:bg-sumi-500
|
|
43
|
-
disabled:text-white-1000
|
|
44
|
-
`
|
|
45
|
-
const secondary = `
|
|
46
|
-
text-sea-800
|
|
47
|
-
bg-transparent
|
|
48
|
-
active:enabled:bg-sea-50/[.60]
|
|
49
|
-
hover:enabled:bg-sea-50
|
|
50
|
-
active:enabled:text-sea-800/[.85]
|
|
51
|
-
hover:enabled:text-sea-800/[.85]
|
|
52
|
-
disabled:text-sumi-500
|
|
53
|
-
`
|
|
54
|
-
|
|
55
|
-
const styles = {
|
|
56
|
-
primary: primary,
|
|
57
|
-
secondary: secondary
|
|
58
|
-
}
|
|
13
|
+
const {
|
|
14
|
+
as: Component = 'button',
|
|
15
|
+
variant = 'primary',
|
|
16
|
+
size = 'lg',
|
|
17
|
+
className,
|
|
18
|
+
children,
|
|
19
|
+
...restProps
|
|
20
|
+
} = props
|
|
59
21
|
|
|
60
22
|
return (
|
|
61
|
-
<
|
|
62
|
-
className={cx(
|
|
23
|
+
<Component
|
|
24
|
+
className={cx(
|
|
25
|
+
base,
|
|
26
|
+
getVariantStyle(variant),
|
|
27
|
+
getSizeStyle(size),
|
|
28
|
+
className
|
|
29
|
+
)}
|
|
63
30
|
{...restProps}
|
|
64
31
|
ref={ref}
|
|
65
32
|
>
|
|
66
33
|
{children}
|
|
67
|
-
</
|
|
34
|
+
</Component>
|
|
68
35
|
)
|
|
69
36
|
}
|
|
70
37
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { cx } from '../
|
|
2
|
+
import { cx } from '../libs/cx'
|
|
3
3
|
|
|
4
4
|
interface IdContextType {
|
|
5
5
|
id: string
|
|
@@ -23,8 +23,6 @@ export const Card = (props: CardProps) => {
|
|
|
23
23
|
sm:rounded-3xl
|
|
24
24
|
text-sumi-900
|
|
25
25
|
overflow-hidden
|
|
26
|
-
flex
|
|
27
|
-
flex-col
|
|
28
26
|
`
|
|
29
27
|
|
|
30
28
|
return (
|
|
@@ -48,21 +46,22 @@ export const CardHeader = (props: CardHeaderProps) => {
|
|
|
48
46
|
const ctx = React.useContext(IdContext)
|
|
49
47
|
|
|
50
48
|
const style = `
|
|
51
|
-
py-6
|
|
52
49
|
px-6
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
first:pt-6
|
|
51
|
+
last:pb-6
|
|
52
|
+
py-3
|
|
53
|
+
text-base
|
|
54
|
+
font-medium
|
|
56
55
|
`
|
|
57
56
|
|
|
58
57
|
return (
|
|
59
|
-
<
|
|
58
|
+
<div id={ctx.id} className={cx(style, className)} {...restProps}>
|
|
60
59
|
{children}
|
|
61
|
-
</
|
|
60
|
+
</div>
|
|
62
61
|
)
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
export interface CardBodyProps extends React.ComponentPropsWithoutRef<'
|
|
64
|
+
export interface CardBodyProps extends React.ComponentPropsWithoutRef<'div'> {}
|
|
66
65
|
|
|
67
66
|
export const CardBody = (props: CardBodyProps) => {
|
|
68
67
|
const { className, children, ...restProps } = props
|
|
@@ -70,8 +69,9 @@ export const CardBody = (props: CardBodyProps) => {
|
|
|
70
69
|
const style = `
|
|
71
70
|
px-6
|
|
72
71
|
first:pt-6
|
|
73
|
-
pb-6
|
|
74
|
-
|
|
72
|
+
last:pb-6
|
|
73
|
+
pb-3
|
|
74
|
+
text-base-sm
|
|
75
75
|
`
|
|
76
76
|
|
|
77
77
|
return (
|
|
@@ -88,10 +88,10 @@ export const CardFooter = (props: CardFooterProps) => {
|
|
|
88
88
|
const { className, children, ...restProps } = props
|
|
89
89
|
|
|
90
90
|
const style = `
|
|
91
|
-
mt-auto
|
|
92
91
|
px-6
|
|
93
92
|
first:pt-6
|
|
94
|
-
pb-6
|
|
93
|
+
last:pb-6
|
|
94
|
+
text-base-sm
|
|
95
95
|
`
|
|
96
96
|
|
|
97
97
|
return (
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { cx } from '../
|
|
2
|
+
import { cx } from '../libs/cx'
|
|
3
3
|
|
|
4
4
|
export interface FaqProps extends React.ComponentPropsWithoutRef<'dl'> {}
|
|
5
5
|
|
|
6
6
|
const headingStyle = `
|
|
7
7
|
text-h-med-m
|
|
8
8
|
sm:text-h-med
|
|
9
|
-
!leading-none
|
|
10
9
|
`
|
|
11
10
|
|
|
12
11
|
export const Faq = (props: FaqProps) => {
|
|
@@ -41,16 +40,17 @@ export const Question = (props: QuestionProps) => {
|
|
|
41
40
|
flex
|
|
42
41
|
flex-row
|
|
43
42
|
gap-8
|
|
43
|
+
mt-8
|
|
44
44
|
`
|
|
45
45
|
return (
|
|
46
|
-
<
|
|
46
|
+
<dt
|
|
47
47
|
className={cx(style, headingStyle, className)}
|
|
48
48
|
itemProp="name"
|
|
49
49
|
{...restProps}
|
|
50
50
|
>
|
|
51
51
|
<span aria-hidden="true">Q</span>
|
|
52
52
|
<span>{children}</span>
|
|
53
|
-
</
|
|
53
|
+
</dt>
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -73,7 +73,7 @@ export const Answer = (props: AnswerProps) => {
|
|
|
73
73
|
itemType="https://schema.org/Answer"
|
|
74
74
|
{...restProps}
|
|
75
75
|
>
|
|
76
|
-
<span className={headingStyle} aria-hidden="true">
|
|
76
|
+
<span className={cx(headingStyle, '!leading-none')} aria-hidden="true">
|
|
77
77
|
A
|
|
78
78
|
</span>
|
|
79
79
|
<span itemProp="text">{children}</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { cx } from '../
|
|
2
|
+
import { cx } from '../libs/cx'
|
|
3
3
|
|
|
4
4
|
export interface IconProps extends React.ComponentPropsWithRef<'span'> {
|
|
5
5
|
icon: string
|
|
@@ -9,14 +9,10 @@ export const Icon = React.forwardRef<HTMLElement, IconProps>((props, ref) => {
|
|
|
9
9
|
const { className, icon, ...restProps } = props
|
|
10
10
|
|
|
11
11
|
const style = `
|
|
12
|
-
inline
|
|
12
|
+
inline
|
|
13
13
|
align-middle
|
|
14
14
|
font-icon
|
|
15
|
-
text-2xl
|
|
16
|
-
font-light
|
|
17
|
-
leading-none
|
|
18
15
|
antialiased
|
|
19
|
-
mb-1
|
|
20
16
|
`
|
|
21
17
|
|
|
22
18
|
return (
|
|
@@ -1,107 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { cx } from '../libs/cx'
|
|
2
|
+
import { ComponentWithAs } from '../types/component'
|
|
3
|
+
import { forwardRef } from '../libs/forward-ref'
|
|
4
|
+
import { base, getVariantStyle, getSizeStyle } from './buttonStyle'
|
|
3
5
|
|
|
4
|
-
export interface IconButtonProps
|
|
6
|
+
export interface IconButtonProps {
|
|
5
7
|
variant?: 'primary' | 'secondary'
|
|
8
|
+
size?: 'lg' | 'md' | 'sm' | 'xs'
|
|
6
9
|
iconLayout?: 'left' | 'right'
|
|
7
|
-
rounded?: string
|
|
8
10
|
icon: string
|
|
11
|
+
rounded?: string
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
export const IconButton
|
|
12
|
-
(props, ref) => {
|
|
14
|
+
export const IconButton: ComponentWithAs<'button', IconButtonProps> =
|
|
15
|
+
forwardRef((props, ref) => {
|
|
13
16
|
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
as: Component = 'button',
|
|
18
|
+
variant = 'primary',
|
|
19
|
+
size = 'lg',
|
|
20
|
+
iconLayout = 'left',
|
|
17
21
|
icon,
|
|
18
|
-
iconLayout,
|
|
19
22
|
rounded,
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
20
25
|
...restProps
|
|
21
26
|
} = props
|
|
22
27
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const align = 'center'
|
|
26
|
-
|
|
27
|
-
const style = `
|
|
28
|
-
${rounded === 'full' ? 'aspect-square' : ''}
|
|
29
|
-
inline-block
|
|
30
|
-
p-4
|
|
31
|
-
text-button
|
|
32
|
-
text-${align}
|
|
33
|
-
rounded-${rounded ? rounded : 'lg'}
|
|
34
|
-
cursor-pointer
|
|
35
|
-
whitespace-nowrap
|
|
36
|
-
border
|
|
37
|
-
border-solid
|
|
38
|
-
border-sea-800
|
|
39
|
-
active:enabled:border-sea-800/[.8]
|
|
40
|
-
hover:enabled:border-sea-800/[.85]
|
|
41
|
-
focus:outline
|
|
42
|
-
focus:outline-2
|
|
43
|
-
focus:outline-wood-600
|
|
44
|
-
disabled:border-sumi-500
|
|
45
|
-
disabled:cursor-not-allowed
|
|
46
|
-
`
|
|
28
|
+
const styleFontSize = `${size === 'xs' ? `scale-105` : `scale-125`}`
|
|
47
29
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
text-sea-800
|
|
58
|
-
bg-transparent
|
|
59
|
-
active:enabled:bg-sea-50/[.60]
|
|
60
|
-
hover:enabled:bg-sea-50
|
|
61
|
-
active:enabled:text-sea-800/[.85]
|
|
62
|
-
hover:enabled:text-sea-800/[.85]
|
|
63
|
-
disabled:text-sumi-500
|
|
64
|
-
`
|
|
30
|
+
const styleIcon = `
|
|
31
|
+
inline-block
|
|
32
|
+
align-middle
|
|
33
|
+
mb-1
|
|
34
|
+
font-icon
|
|
35
|
+
font-light
|
|
36
|
+
leading-[0px]
|
|
37
|
+
antialiased
|
|
38
|
+
`
|
|
65
39
|
|
|
66
|
-
const
|
|
67
|
-
primary: primary,
|
|
68
|
-
secondary: secondary
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const iconStyle = `
|
|
72
|
-
inline-block
|
|
73
|
-
align-middle
|
|
74
|
-
font-icon
|
|
75
|
-
text-2xl
|
|
76
|
-
font-light
|
|
77
|
-
leading-4
|
|
78
|
-
antialiased
|
|
79
|
-
mb-1
|
|
80
|
-
`
|
|
40
|
+
const styleRounded = `${rounded ? `aspect-square !rounded-full !py-0` : ''}`
|
|
81
41
|
|
|
82
42
|
// When text is specified on a button, set the 'aria-hidden' attribute of the icon to true.
|
|
83
43
|
const ariaHidden = children ? true : false
|
|
84
44
|
|
|
85
45
|
return (
|
|
86
|
-
<
|
|
87
|
-
className={cx(
|
|
46
|
+
<Component
|
|
47
|
+
className={cx(
|
|
48
|
+
base,
|
|
49
|
+
getVariantStyle(variant),
|
|
50
|
+
getSizeStyle(size),
|
|
51
|
+
styleRounded,
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
88
54
|
{...restProps}
|
|
89
55
|
ref={ref}
|
|
90
56
|
>
|
|
91
|
-
{
|
|
92
|
-
<span
|
|
57
|
+
{iconLayout == 'left' && (
|
|
58
|
+
<span
|
|
59
|
+
className={cx(styleIcon, styleFontSize)}
|
|
60
|
+
aria-hidden={ariaHidden}
|
|
61
|
+
>
|
|
93
62
|
{icon}
|
|
94
63
|
</span>
|
|
95
64
|
)}
|
|
96
|
-
{children && <span className="mx-1
|
|
97
|
-
{
|
|
98
|
-
<span
|
|
65
|
+
{children && <span className="mx-1">{children}</span>}
|
|
66
|
+
{iconLayout == 'right' && (
|
|
67
|
+
<span
|
|
68
|
+
className={cx(styleIcon, styleFontSize)}
|
|
69
|
+
aria-hidden={ariaHidden}
|
|
70
|
+
>
|
|
99
71
|
{icon}
|
|
100
72
|
</span>
|
|
101
73
|
)}
|
|
102
|
-
</
|
|
74
|
+
</Component>
|
|
103
75
|
)
|
|
104
|
-
}
|
|
105
|
-
)
|
|
76
|
+
})
|
|
106
77
|
|
|
107
78
|
IconButton.displayName = 'IconButton'
|
|
@@ -1,47 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { cx } from '../
|
|
1
|
+
import { useState, useEffect } from 'react'
|
|
2
|
+
import { cx } from '../libs/cx'
|
|
3
|
+
import { ComponentWithAs } from '../types/component'
|
|
4
|
+
import { forwardRef } from '../libs/forward-ref'
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
const converted = url.toLowerCase()
|
|
6
|
+
export interface LinkProps {}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
return 'PDF'
|
|
9
|
-
}
|
|
10
|
-
if (converted.endsWith('.doc') || converted.endsWith('.docx')) {
|
|
11
|
-
return 'Word'
|
|
12
|
-
}
|
|
13
|
-
if (converted.endsWith('.xls') || converted.endsWith('.xlsx')) {
|
|
14
|
-
return 'Excel'
|
|
15
|
-
}
|
|
16
|
-
if (converted.endsWith('.csv')) {
|
|
17
|
-
return 'CSV'
|
|
18
|
-
}
|
|
19
|
-
if (converted.endsWith('.json')) {
|
|
20
|
-
return 'JSON'
|
|
21
|
-
}
|
|
22
|
-
if (converted.endsWith('.ndjson')) {
|
|
23
|
-
return 'NDJSON'
|
|
24
|
-
}
|
|
25
|
-
if (converted.includes('youtu.be')) {
|
|
26
|
-
return 'YouTube'
|
|
27
|
-
}
|
|
28
|
-
return null
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface LinkProps extends React.ComponentPropsWithRef<'a'> {}
|
|
32
|
-
|
|
33
|
-
export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
8
|
+
export const Link: ComponentWithAs<'a', LinkProps> = forwardRef(
|
|
34
9
|
(props, ref) => {
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
10
|
+
const {
|
|
11
|
+
as: Component = 'a',
|
|
12
|
+
href,
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...restProps
|
|
16
|
+
} = props
|
|
17
|
+
|
|
18
|
+
const styleUnderLine = `
|
|
19
|
+
underline
|
|
20
|
+
underline-offset-[0.125em]
|
|
21
|
+
`
|
|
38
22
|
|
|
39
23
|
const style = `
|
|
40
24
|
rounded-sm
|
|
41
25
|
cursor-pointer
|
|
42
26
|
text-sea-600
|
|
43
|
-
underline
|
|
44
|
-
underline-offset-[0.125em]
|
|
45
27
|
hover:text-sea-800
|
|
46
28
|
active:text-sea-800
|
|
47
29
|
visited:text-sea-900
|
|
@@ -51,9 +33,30 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
51
33
|
disabled:border-sumi-500
|
|
52
34
|
`
|
|
53
35
|
|
|
54
|
-
|
|
36
|
+
const styleIcon = `
|
|
37
|
+
align-middle
|
|
38
|
+
ml-0.5
|
|
39
|
+
text-sumi-700
|
|
40
|
+
font-icon
|
|
41
|
+
font-light
|
|
42
|
+
leading-4
|
|
43
|
+
antialiased
|
|
44
|
+
`
|
|
45
|
+
|
|
46
|
+
const [iconLabel, setIconLabel] = useState('')
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const language =
|
|
49
|
+
(window.navigator.languages && window.navigator.languages[0]) ||
|
|
50
|
+
window.navigator.language
|
|
51
|
+
if (language === 'ja') {
|
|
52
|
+
setIconLabel('新規タブで開きます')
|
|
53
|
+
}
|
|
54
|
+
setIconLabel('Opens in new tab')
|
|
55
|
+
}, [])
|
|
56
|
+
|
|
57
|
+
if (href?.startsWith('http')) {
|
|
55
58
|
return (
|
|
56
|
-
<
|
|
59
|
+
<Component
|
|
57
60
|
className={cx(style, className)}
|
|
58
61
|
href={href}
|
|
59
62
|
target="_blank"
|
|
@@ -61,16 +64,22 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
61
64
|
{...restProps}
|
|
62
65
|
ref={ref}
|
|
63
66
|
>
|
|
64
|
-
{children}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
<span className={styleUnderLine}>{children}</span>
|
|
68
|
+
<span className={cx(styleIcon)} aria-label={iconLabel}>
|
|
69
|
+
open_in_new
|
|
70
|
+
</span>
|
|
71
|
+
</Component>
|
|
67
72
|
)
|
|
68
73
|
}
|
|
69
74
|
return (
|
|
70
|
-
<
|
|
75
|
+
<Component
|
|
76
|
+
className={cx(style, styleUnderLine, className)}
|
|
77
|
+
href={href}
|
|
78
|
+
{...restProps}
|
|
79
|
+
ref={ref}
|
|
80
|
+
>
|
|
71
81
|
{children}
|
|
72
|
-
|
|
73
|
-
</a>
|
|
82
|
+
</Component>
|
|
74
83
|
)
|
|
75
84
|
}
|
|
76
85
|
)
|