@instructure/ui-link 11.6.0 → 11.6.1-snapshot-129
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/CHANGELOG.md +40 -288
- package/es/Link/{index.js → v1/index.js} +2 -2
- package/es/Link/v2/index.js +253 -0
- package/es/Link/v2/props.js +26 -0
- package/es/Link/v2/styles.js +242 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -3
- package/lib/Link/{index.js → v1/index.js} +3 -3
- package/lib/Link/v2/index.js +262 -0
- package/lib/Link/v2/props.js +31 -0
- package/lib/Link/v2/styles.js +248 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +43 -21
- package/src/Link/{index.tsx → v1/index.tsx} +3 -3
- package/src/Link/{props.ts → v1/props.ts} +1 -1
- package/src/Link/v2/README.md +261 -0
- package/src/Link/v2/index.tsx +321 -0
- package/src/Link/v2/props.ts +184 -0
- package/src/Link/v2/styles.ts +267 -0
- package/src/exports/a.ts +26 -0
- package/src/exports/b.ts +26 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Link/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/Link/v1/index.d.ts.map +1 -0
- package/types/Link/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/Link/v1/props.d.ts.map +1 -0
- package/types/Link/v1/styles.d.ts.map +1 -0
- package/types/Link/v1/theme.d.ts.map +1 -0
- package/types/Link/v2/index.d.ts +66 -0
- package/types/Link/v2/index.d.ts.map +1 -0
- package/types/Link/v2/props.d.ts +105 -0
- package/types/Link/v2/props.d.ts.map +1 -0
- package/types/Link/v2/styles.d.ts +19 -0
- package/types/Link/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Link/index.d.ts.map +0 -1
- package/types/Link/props.d.ts.map +0 -1
- package/types/Link/styles.d.ts.map +0 -1
- package/types/Link/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/Link/{props.js → v1/props.js} +0 -0
- /package/es/Link/{styles.js → v1/styles.js} +0 -0
- /package/es/Link/{theme.js → v1/theme.js} +0 -0
- /package/lib/Link/{props.js → v1/props.js} +0 -0
- /package/lib/Link/{styles.js → v1/styles.js} +0 -0
- /package/lib/Link/{theme.js → v1/theme.js} +0 -0
- /package/src/Link/{README.md → v1/README.md} +0 -0
- /package/src/Link/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Link/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Link/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Link/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import type {
|
|
27
|
+
ToProp,
|
|
28
|
+
AsElementType,
|
|
29
|
+
LinkTheme,
|
|
30
|
+
OtherHTMLAttributes
|
|
31
|
+
} from '@instructure/shared-types'
|
|
32
|
+
import type {
|
|
33
|
+
Spacing,
|
|
34
|
+
WithStyleProps,
|
|
35
|
+
ComponentStyle
|
|
36
|
+
} from '@instructure/emotion'
|
|
37
|
+
import type { ViewOwnProps } from '@instructure/ui-view/latest'
|
|
38
|
+
import { Renderable } from '@instructure/shared-types'
|
|
39
|
+
|
|
40
|
+
type LinkOwnProps = {
|
|
41
|
+
/**
|
|
42
|
+
* The text and/or icon displayed by the link
|
|
43
|
+
*/
|
|
44
|
+
children: React.ReactNode
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sets the link's `href` attribute
|
|
48
|
+
*/
|
|
49
|
+
href?: string
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Designates Link's text color to accommodate light and dark backgrounds
|
|
53
|
+
*/
|
|
54
|
+
color?: 'link' | 'link-inverse'
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Provides a reference to the underlying HTML element
|
|
58
|
+
*/
|
|
59
|
+
elementRef?: (element: Element | null) => void
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
63
|
+
*/
|
|
64
|
+
as?: AsElementType
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The ARIA role of the element.
|
|
68
|
+
*/
|
|
69
|
+
role?: string
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* If the Link has an onClick handler but is not a button element,
|
|
73
|
+
* force ARIA role to be "button".
|
|
74
|
+
*/
|
|
75
|
+
forceButtonRole?: boolean
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Determines if the link is enabled or disabled
|
|
79
|
+
*/
|
|
80
|
+
interaction?: 'enabled' | 'disabled'
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Valid values are `0`, `none`, `auto`, and Spacing token values,
|
|
84
|
+
* see https://instructure.design/layout-spacing. Apply these values via
|
|
85
|
+
* familiar CSS-like shorthand. For example, `margin="small auto large"`.
|
|
86
|
+
*/
|
|
87
|
+
margin?: Spacing
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Add an SVG icon to the Link. Do not add icons directly as
|
|
91
|
+
* children.
|
|
92
|
+
* When using Lucide icons, Link will automatically pass the appropriate size prop based on the Link's size.
|
|
93
|
+
*/
|
|
94
|
+
renderIcon?: Renderable
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Place the icon before or after the text in the Link.
|
|
98
|
+
*/
|
|
99
|
+
iconPlacement?: 'start' | 'end'
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Set the CSS display property of the Link element. 'auto' sets no display property.
|
|
103
|
+
*/
|
|
104
|
+
display?: 'auto' | 'block' | 'inline-block' | 'flex' | 'inline-flex'
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Fires when the Link loses focus
|
|
108
|
+
*/
|
|
109
|
+
onBlur?: (event: React.FocusEvent<ViewOwnProps>) => void
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Fires when the Link is clicked
|
|
113
|
+
*/
|
|
114
|
+
onClick?: (event: React.MouseEvent<ViewOwnProps>) => void
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Fires when the Link gains focus
|
|
118
|
+
*/
|
|
119
|
+
onFocus?: (event: React.FocusEvent<ViewOwnProps>) => void
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Fires when the Link is hovered
|
|
123
|
+
*/
|
|
124
|
+
onMouseEnter?: (event: React.MouseEvent<ViewOwnProps>) => void
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Sets pre-defined values for the component to achieve specific roles for the component
|
|
128
|
+
* - `inline`
|
|
129
|
+
* - `standalone`
|
|
130
|
+
*
|
|
131
|
+
* __Deprecated values:__
|
|
132
|
+
* - `inline-small`
|
|
133
|
+
* - `standalone-small`
|
|
134
|
+
*/
|
|
135
|
+
variant?: 'inline' | 'standalone' | 'inline-small' | 'standalone-small'
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Sets the size of the link (font size, line height, and icon gap)
|
|
139
|
+
*/
|
|
140
|
+
size?: 'small' | 'medium' | 'large'
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type LinkStyleProps = {
|
|
144
|
+
containsTruncateText: boolean
|
|
145
|
+
hasVisibleChildren: boolean
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type PropKeys = keyof LinkOwnProps
|
|
149
|
+
|
|
150
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
151
|
+
|
|
152
|
+
type LinkState = {
|
|
153
|
+
hasFocus: boolean
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type LinkProps = LinkOwnProps &
|
|
157
|
+
WithStyleProps<LinkTheme, LinkStyle> &
|
|
158
|
+
OtherHTMLAttributes<LinkOwnProps> &
|
|
159
|
+
ToProp
|
|
160
|
+
|
|
161
|
+
type LinkStyle = ComponentStyle<'link' | 'icon'>
|
|
162
|
+
const allowedProps: AllowedPropKeys = [
|
|
163
|
+
'children',
|
|
164
|
+
'href',
|
|
165
|
+
'color',
|
|
166
|
+
'elementRef',
|
|
167
|
+
'as',
|
|
168
|
+
'role',
|
|
169
|
+
'forceButtonRole',
|
|
170
|
+
'interaction',
|
|
171
|
+
'margin',
|
|
172
|
+
'renderIcon',
|
|
173
|
+
'iconPlacement',
|
|
174
|
+
'display',
|
|
175
|
+
'onBlur',
|
|
176
|
+
'onClick',
|
|
177
|
+
'onFocus',
|
|
178
|
+
'onMouseEnter',
|
|
179
|
+
'size',
|
|
180
|
+
'variant'
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
export type { LinkProps, LinkState, LinkStyle }
|
|
184
|
+
export { allowedProps }
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
26
|
+
import type { LinkProps, LinkStyle, LinkStyleProps } from './props'
|
|
27
|
+
import {
|
|
28
|
+
calcFocusOutlineStyles,
|
|
29
|
+
calcSpacingFromShorthand
|
|
30
|
+
} from '@instructure/emotion'
|
|
31
|
+
/**
|
|
32
|
+
* ---
|
|
33
|
+
* private: true
|
|
34
|
+
* ---
|
|
35
|
+
* Generates the style object from the theme and provided additional information
|
|
36
|
+
* @param {Object} componentTheme The theme variable object.
|
|
37
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
+
* @param {Object} sharedTokens Shared token object that stores common values for the theme.
|
|
39
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
40
|
+
* @return {Object} The final style object, which will be used in the component
|
|
41
|
+
*/
|
|
42
|
+
const generateStyle = (
|
|
43
|
+
componentTheme: NewComponentTypes['Link'],
|
|
44
|
+
props: LinkProps,
|
|
45
|
+
sharedTokens: SharedTokens,
|
|
46
|
+
state: Partial<
|
|
47
|
+
LinkStyleProps & {
|
|
48
|
+
variant?: 'inline' | 'standalone'
|
|
49
|
+
size?: 'small' | 'medium' | 'large'
|
|
50
|
+
}
|
|
51
|
+
> = {}
|
|
52
|
+
): LinkStyle => {
|
|
53
|
+
const {
|
|
54
|
+
renderIcon,
|
|
55
|
+
iconPlacement = 'start', // TODO workaround needed for react 19 where defaultprops doesn't apply for some reasong
|
|
56
|
+
color,
|
|
57
|
+
margin
|
|
58
|
+
} = props
|
|
59
|
+
|
|
60
|
+
// Get size and variant from state (passed from makeStyleProps) or fall back to props
|
|
61
|
+
const size = state.size ?? props.size
|
|
62
|
+
const variant = state.variant ?? props.variant
|
|
63
|
+
const hasVisibleChildren = state.hasVisibleChildren ?? false
|
|
64
|
+
const isInverseStyle = color === 'link-inverse'
|
|
65
|
+
|
|
66
|
+
const inlineLinkSizeStyles = {
|
|
67
|
+
small: {
|
|
68
|
+
fontFamily: componentTheme.inlineLink.small.fontFamily,
|
|
69
|
+
fontWeight: componentTheme.inlineLink.small.fontWeight,
|
|
70
|
+
fontSize: componentTheme.inlineLink.small.fontSize,
|
|
71
|
+
lineHeight: componentTheme.inlineLink.small.lineHeight,
|
|
72
|
+
textDecoration: componentTheme.inlineLink.small.textDecoration,
|
|
73
|
+
gap: componentTheme.gapSm
|
|
74
|
+
},
|
|
75
|
+
medium: {
|
|
76
|
+
fontFamily: componentTheme.inlineLink.medium.fontFamily,
|
|
77
|
+
fontWeight: componentTheme.inlineLink.medium.fontWeight,
|
|
78
|
+
fontSize: componentTheme.inlineLink.medium.fontSize,
|
|
79
|
+
lineHeight: componentTheme.inlineLink.medium.lineHeight,
|
|
80
|
+
textDecoration: componentTheme.inlineLink.medium.textDecoration,
|
|
81
|
+
gap: componentTheme.gapMd
|
|
82
|
+
},
|
|
83
|
+
large: {
|
|
84
|
+
fontFamily: componentTheme.inlineLink.large.fontFamily,
|
|
85
|
+
fontWeight: componentTheme.inlineLink.large.fontWeight,
|
|
86
|
+
fontSize: componentTheme.inlineLink.large.fontSize,
|
|
87
|
+
lineHeight: componentTheme.inlineLink.large.lineHeight,
|
|
88
|
+
textDecoration: componentTheme.inlineLink.large.textDecoration,
|
|
89
|
+
gap: componentTheme.gapLg
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// For standalone variant, use the base component theme tokens
|
|
94
|
+
const standaloneLinkSizeStyles = {
|
|
95
|
+
small: {
|
|
96
|
+
fontFamily: componentTheme.fontFamily,
|
|
97
|
+
fontWeight: componentTheme.fontWeight,
|
|
98
|
+
fontSize: componentTheme.fontSizeSm,
|
|
99
|
+
lineHeight: componentTheme.lineHeightSm,
|
|
100
|
+
textDecoration: 'none',
|
|
101
|
+
gap: componentTheme.gapSm
|
|
102
|
+
},
|
|
103
|
+
medium: {
|
|
104
|
+
fontFamily: componentTheme.fontFamily,
|
|
105
|
+
fontWeight: componentTheme.fontWeight,
|
|
106
|
+
fontSize: componentTheme.fontSizeMd,
|
|
107
|
+
lineHeight: componentTheme.lineHeightMd,
|
|
108
|
+
textDecoration: 'none',
|
|
109
|
+
gap: componentTheme.gapMd
|
|
110
|
+
},
|
|
111
|
+
large: {
|
|
112
|
+
fontFamily: componentTheme.fontFamily,
|
|
113
|
+
fontWeight: componentTheme.fontWeight,
|
|
114
|
+
fontSize: componentTheme.fontSizeLg,
|
|
115
|
+
lineHeight: componentTheme.lineHeightLg,
|
|
116
|
+
textDecoration: 'none',
|
|
117
|
+
gap: componentTheme.gapLg
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Get proper styles based on variant and size
|
|
122
|
+
let variantStyles
|
|
123
|
+
if (size && variant === 'inline') {
|
|
124
|
+
variantStyles = inlineLinkSizeStyles[size]
|
|
125
|
+
} else if (size && variant === 'standalone') {
|
|
126
|
+
variantStyles = standaloneLinkSizeStyles[size]
|
|
127
|
+
} else if (size) {
|
|
128
|
+
// Fallback if variant is not specified but size is
|
|
129
|
+
variantStyles = standaloneLinkSizeStyles[size]
|
|
130
|
+
} else {
|
|
131
|
+
// No size provided, use inherit
|
|
132
|
+
variantStyles = {
|
|
133
|
+
fontSize: 'inherit' as const,
|
|
134
|
+
lineHeight: 'inherit' as const,
|
|
135
|
+
textDecoration: undefined,
|
|
136
|
+
gap: componentTheme.gapMd // Default gap for icons when no size is specified
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const baseStyles = {
|
|
141
|
+
boxSizing: 'border-box',
|
|
142
|
+
fontFamily: componentTheme.fontFamily,
|
|
143
|
+
fontWeight: componentTheme.fontWeight,
|
|
144
|
+
verticalAlign: 'baseline',
|
|
145
|
+
fontSize: variantStyles.fontSize,
|
|
146
|
+
lineHeight: variantStyles.lineHeight,
|
|
147
|
+
color: componentTheme.unstyledTextColor,
|
|
148
|
+
|
|
149
|
+
// set up focus styles
|
|
150
|
+
borderRadius: '0.125rem',
|
|
151
|
+
|
|
152
|
+
// If icon is present, use flex to align icon with text
|
|
153
|
+
// Use 'flex' for standalone variant (block-level), 'inline-flex' for inline variant
|
|
154
|
+
...(renderIcon &&
|
|
155
|
+
hasVisibleChildren && {
|
|
156
|
+
display: variant === 'standalone' ? 'flex' : 'inline-flex',
|
|
157
|
+
alignItems: 'baseline'
|
|
158
|
+
}),
|
|
159
|
+
|
|
160
|
+
'&[aria-disabled]': {
|
|
161
|
+
cursor: 'not-allowed',
|
|
162
|
+
pointerEvents: 'none',
|
|
163
|
+
opacity: '1',
|
|
164
|
+
color: componentTheme.textDisabledColor
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// If Link is a button or link, it should look clickable
|
|
169
|
+
const isClickableStyles = {
|
|
170
|
+
...baseStyles,
|
|
171
|
+
cursor: 'pointer',
|
|
172
|
+
color: componentTheme.textColor,
|
|
173
|
+
fontSize: variantStyles.fontSize,
|
|
174
|
+
lineHeight: variantStyles.lineHeight,
|
|
175
|
+
...(variantStyles.fontFamily && { fontFamily: variantStyles.fontFamily }),
|
|
176
|
+
...(variantStyles.fontWeight && { fontWeight: variantStyles.fontWeight }),
|
|
177
|
+
'&:hover, &:active, &:focus': {
|
|
178
|
+
color: componentTheme.textHoverColor,
|
|
179
|
+
// a11y requirement: interactive links must be underlined on interaction
|
|
180
|
+
textDecoration: 'underline'
|
|
181
|
+
},
|
|
182
|
+
// Use textDecoration from variantStyles if available (from inlineLink token), otherwise fallback
|
|
183
|
+
...(variantStyles.textDecoration
|
|
184
|
+
? { textDecoration: variantStyles.textDecoration }
|
|
185
|
+
: { textDecoration: 'underline' })
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const buttonStyle = {
|
|
189
|
+
appearance: 'none',
|
|
190
|
+
userSelect: 'text',
|
|
191
|
+
background: 'none',
|
|
192
|
+
border: 'none',
|
|
193
|
+
cursor: 'pointer',
|
|
194
|
+
margin: 0,
|
|
195
|
+
padding: 0,
|
|
196
|
+
textAlign: 'inherit',
|
|
197
|
+
fontSize: variantStyles.fontSize,
|
|
198
|
+
lineHeight: variantStyles.lineHeight,
|
|
199
|
+
...(variantStyles.textDecoration && {
|
|
200
|
+
textDecoration: variantStyles.textDecoration
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const inverseStyles = {
|
|
205
|
+
color: componentTheme.onColorTextColor,
|
|
206
|
+
// TODO remove double (here with the util and in View) focus ring calculations
|
|
207
|
+
// in the future after the View refactor is complete
|
|
208
|
+
// This needs stronger specificity than `View`
|
|
209
|
+
'&&&&&:focus': {
|
|
210
|
+
outlineColor: sharedTokens.focusOutline.onColor
|
|
211
|
+
},
|
|
212
|
+
'&:hover, &:active': {
|
|
213
|
+
color: componentTheme.onColorTextHoverColor
|
|
214
|
+
},
|
|
215
|
+
'&[aria-disabled]': {
|
|
216
|
+
color: componentTheme.onColorTextDisabledColor
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Icon styles based on size - use gap from variantStyles
|
|
221
|
+
const iconStyles = {
|
|
222
|
+
paddingInlineStart:
|
|
223
|
+
iconPlacement === 'start' ? 0 : variantStyles.gap || componentTheme.gapMd,
|
|
224
|
+
paddingInlineEnd:
|
|
225
|
+
iconPlacement === 'start' ? variantStyles.gap || componentTheme.gapMd : 0
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
link: {
|
|
230
|
+
label: 'link',
|
|
231
|
+
...baseStyles,
|
|
232
|
+
// TODO handle the merging on tokens inside the util
|
|
233
|
+
margin: calcSpacingFromShorthand(margin, {
|
|
234
|
+
...sharedTokens.spacing,
|
|
235
|
+
...sharedTokens.legacy.spacing
|
|
236
|
+
}),
|
|
237
|
+
...calcFocusOutlineStyles(
|
|
238
|
+
sharedTokens.focusOutline,
|
|
239
|
+
isInverseStyle ? { focusColor: 'inverse' } : undefined
|
|
240
|
+
),
|
|
241
|
+
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
|
|
242
|
+
'&:is(a), &:is(button)': isClickableStyles,
|
|
243
|
+
'&:-webkit-any(a), &:-webkit-any(button)': isClickableStyles,
|
|
244
|
+
|
|
245
|
+
'&:is(button)': buttonStyle,
|
|
246
|
+
'&:-webkit-any(button)': buttonStyle,
|
|
247
|
+
|
|
248
|
+
...(isInverseStyle && {
|
|
249
|
+
...inverseStyles,
|
|
250
|
+
'&:is(a):link, &:is(a):visited, &:is(button)': inverseStyles,
|
|
251
|
+
'&:-webkit-any(a):link, &:-webkit-any(a):visited, &:-webkit-any(button)':
|
|
252
|
+
inverseStyles
|
|
253
|
+
})
|
|
254
|
+
},
|
|
255
|
+
icon: {
|
|
256
|
+
label: 'icon',
|
|
257
|
+
...(renderIcon && {
|
|
258
|
+
boxSizing: 'border-box',
|
|
259
|
+
display: 'flex',
|
|
260
|
+
alignSelf: 'center',
|
|
261
|
+
...iconStyles
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export default generateStyle
|
package/src/exports/a.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export { Link } from '../Link/v1'
|
|
26
|
+
export type { LinkProps } from '../Link/v1/props'
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export { Link } from '../Link/v2'
|
|
26
|
+
export type { LinkProps } from '../Link/v2/props'
|