@instructure/ui-byline 11.7.2-snapshot-21 → 11.7.2-snapshot-22
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 +5 -2
- package/es/Byline/v2/index.js +86 -0
- package/es/Byline/v2/props.js +26 -0
- package/es/Byline/v2/styles.js +105 -0
- package/es/exports/b.js +24 -0
- package/lib/Byline/v2/index.js +91 -0
- package/lib/Byline/v2/props.js +31 -0
- package/lib/Byline/v2/styles.js +111 -0
- package/lib/exports/b.js +12 -0
- package/package.json +19 -19
- package/src/Byline/v2/README.md +59 -0
- package/src/Byline/v2/index.tsx +103 -0
- package/src/Byline/v2/props.ts +93 -0
- package/src/Byline/v2/styles.ts +116 -0
- package/src/exports/b.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Byline/v2/index.d.ts +30 -0
- package/types/Byline/v2/index.d.ts.map +1 -0
- package/types/Byline/v2/props.d.ts +42 -0
- package/types/Byline/v2/props.d.ts.map +1 -0
- package/types/Byline/v2/styles.d.ts +15 -0
- package/types/Byline/v2/styles.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
|
@@ -0,0 +1,103 @@
|
|
|
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 { Component } from 'react'
|
|
26
|
+
|
|
27
|
+
import { omitProps } from '@instructure/ui-react-utils'
|
|
28
|
+
import { View } from '@instructure/ui-view/latest'
|
|
29
|
+
|
|
30
|
+
import { withStyle } from '@instructure/emotion'
|
|
31
|
+
|
|
32
|
+
import generateStyle from './styles'
|
|
33
|
+
|
|
34
|
+
import { allowedProps } from './props'
|
|
35
|
+
import type { BylineProps } from './props'
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
---
|
|
39
|
+
category: components
|
|
40
|
+
---
|
|
41
|
+
**/
|
|
42
|
+
|
|
43
|
+
@withStyle(generateStyle)
|
|
44
|
+
class Byline extends Component<BylineProps> {
|
|
45
|
+
static readonly componentId = 'Byline'
|
|
46
|
+
|
|
47
|
+
static allowedProps = allowedProps
|
|
48
|
+
static defaultProps = {
|
|
49
|
+
alignContent: 'center'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ref: Element | null = null
|
|
53
|
+
|
|
54
|
+
handleRef = (el: Element | null) => {
|
|
55
|
+
const { elementRef } = this.props
|
|
56
|
+
|
|
57
|
+
this.ref = el
|
|
58
|
+
|
|
59
|
+
if (typeof elementRef === 'function') {
|
|
60
|
+
elementRef(el)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
componentDidMount() {
|
|
65
|
+
this.props.makeStyles?.()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
componentDidUpdate() {
|
|
69
|
+
this.props.makeStyles?.()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
const passthroughProps = View.omitViewProps(
|
|
74
|
+
omitProps(this.props, Byline.allowedProps),
|
|
75
|
+
Byline
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<View
|
|
80
|
+
{...passthroughProps}
|
|
81
|
+
elementRef={this.handleRef}
|
|
82
|
+
css={this.props.styles?.byline}
|
|
83
|
+
margin={this.props.margin}
|
|
84
|
+
maxWidth={this.props.styles?.maxWidth}
|
|
85
|
+
>
|
|
86
|
+
<div css={this.props.styles?.figure}>{this.props.children}</div>
|
|
87
|
+
<div css={this.props.styles?.caption}>
|
|
88
|
+
{this.props.title && (
|
|
89
|
+
<span css={this.props.styles?.title}>{this.props.title}</span>
|
|
90
|
+
)}
|
|
91
|
+
{this.props.description && (
|
|
92
|
+
<div css={this.props.styles?.description}>
|
|
93
|
+
{this.props.description}
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
</View>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default Byline
|
|
103
|
+
export { Byline }
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
Spacing,
|
|
28
|
+
WithStyleProps,
|
|
29
|
+
ComponentStyle
|
|
30
|
+
} from '@instructure/emotion'
|
|
31
|
+
import type {
|
|
32
|
+
BylineTheme,
|
|
33
|
+
OtherHTMLAttributes
|
|
34
|
+
} from '@instructure/shared-types'
|
|
35
|
+
|
|
36
|
+
type BylineOwnProps = {
|
|
37
|
+
/**
|
|
38
|
+
* the Byline visual/object
|
|
39
|
+
*/
|
|
40
|
+
children: React.ReactNode
|
|
41
|
+
/**
|
|
42
|
+
* the Byline title
|
|
43
|
+
*/
|
|
44
|
+
title?: React.ReactNode
|
|
45
|
+
/**
|
|
46
|
+
* the Byline description
|
|
47
|
+
*/
|
|
48
|
+
description?: string | React.ReactNode
|
|
49
|
+
/**
|
|
50
|
+
* how should the title and description align
|
|
51
|
+
*/
|
|
52
|
+
alignContent?: 'top' | 'center'
|
|
53
|
+
/**
|
|
54
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
55
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
56
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
57
|
+
*/
|
|
58
|
+
margin?: Spacing
|
|
59
|
+
/*
|
|
60
|
+
* Determines the `max-width` of this element.
|
|
61
|
+
*/
|
|
62
|
+
size?: 'small' | 'medium' | 'large'
|
|
63
|
+
/**
|
|
64
|
+
* Provides a reference to the underlying html root element
|
|
65
|
+
*/
|
|
66
|
+
elementRef?: (element: Element | null) => void
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type PropKeys = keyof BylineOwnProps
|
|
70
|
+
|
|
71
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
72
|
+
|
|
73
|
+
type BylineProps = BylineOwnProps &
|
|
74
|
+
WithStyleProps<BylineTheme, BylineStyle> &
|
|
75
|
+
OtherHTMLAttributes<BylineOwnProps>
|
|
76
|
+
|
|
77
|
+
type BylineStyle = ComponentStyle<
|
|
78
|
+
'byline' | 'figure' | 'caption' | 'title' | 'description' | 'maxWidth'
|
|
79
|
+
> & {
|
|
80
|
+
maxWidth?: string
|
|
81
|
+
}
|
|
82
|
+
const allowedProps: AllowedPropKeys = [
|
|
83
|
+
'alignContent',
|
|
84
|
+
'children',
|
|
85
|
+
'description',
|
|
86
|
+
'elementRef',
|
|
87
|
+
'margin',
|
|
88
|
+
'size',
|
|
89
|
+
'title'
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
export type { BylineProps, BylineStyle }
|
|
93
|
+
export { allowedProps }
|
|
@@ -0,0 +1,116 @@
|
|
|
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 type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
26
|
+
import type { BylineProps, BylineStyle } from './props'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ---
|
|
30
|
+
* private: true
|
|
31
|
+
* ---
|
|
32
|
+
* Generates the style object from the theme and provided additional information
|
|
33
|
+
* @param componentTheme The theme variable object.
|
|
34
|
+
* @param params Additional parameters to customize the style.
|
|
35
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
36
|
+
* @return The final style object, which will be used in the component
|
|
37
|
+
*/
|
|
38
|
+
const generateStyle = (
|
|
39
|
+
componentTheme: NewComponentTypes['Byline'],
|
|
40
|
+
params: BylineProps,
|
|
41
|
+
_sharedTokens: SharedTokens
|
|
42
|
+
): BylineStyle => {
|
|
43
|
+
const { alignContent, size } = params
|
|
44
|
+
|
|
45
|
+
const widthSizeVariants: Record<string, string> = {
|
|
46
|
+
small: String(componentTheme.small),
|
|
47
|
+
medium: String(componentTheme.medium),
|
|
48
|
+
large: String(componentTheme.large)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const widthSizeVariant = widthSizeVariants[size!]
|
|
52
|
+
|
|
53
|
+
const alignContentVariants = {
|
|
54
|
+
top: { alignItems: 'flex-start' },
|
|
55
|
+
center: { alignItems: 'center' }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const bylineStyles = {
|
|
59
|
+
display: 'flex',
|
|
60
|
+
background: componentTheme.background,
|
|
61
|
+
margin: 0,
|
|
62
|
+
padding: 0,
|
|
63
|
+
fontFamily: componentTheme.fontFamily,
|
|
64
|
+
...alignContentVariants[alignContent!]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const captionStyles = {
|
|
68
|
+
color: componentTheme.color,
|
|
69
|
+
margin: 0,
|
|
70
|
+
padding: 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
byline: {
|
|
75
|
+
label: 'byline',
|
|
76
|
+
...bylineStyles,
|
|
77
|
+
|
|
78
|
+
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
|
|
79
|
+
'&:is(figure)': bylineStyles,
|
|
80
|
+
'&:-webkit-any(figure)': bylineStyles
|
|
81
|
+
},
|
|
82
|
+
figure: {
|
|
83
|
+
label: 'byline__figure',
|
|
84
|
+
marginInlineStart: 0,
|
|
85
|
+
marginInlineEnd: componentTheme.figureMargin
|
|
86
|
+
},
|
|
87
|
+
caption: {
|
|
88
|
+
label: 'byline__caption',
|
|
89
|
+
...captionStyles,
|
|
90
|
+
|
|
91
|
+
// NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
|
|
92
|
+
'&:is(figcaption)': captionStyles,
|
|
93
|
+
'&:-webkit-any(figcaption)': captionStyles
|
|
94
|
+
},
|
|
95
|
+
title: {
|
|
96
|
+
label: 'byline__title',
|
|
97
|
+
textRendering: 'optimizeLegibility',
|
|
98
|
+
WebkitFontSmoothing: 'antialiased',
|
|
99
|
+
MozOsxFontSmoothing: 'grayscale',
|
|
100
|
+
display: 'block',
|
|
101
|
+
margin: componentTheme.titleMargin,
|
|
102
|
+
fontSize: componentTheme.titleFontSize,
|
|
103
|
+
fontWeight: componentTheme.titleFontWeight,
|
|
104
|
+
lineHeight: componentTheme.titleLineHeight
|
|
105
|
+
},
|
|
106
|
+
description: {
|
|
107
|
+
label: 'byline__description',
|
|
108
|
+
fontSize: componentTheme.descriptionFontSize,
|
|
109
|
+
lineHeight: componentTheme.descriptionLineHeight,
|
|
110
|
+
fontWeight: componentTheme.descriptionFontWeight
|
|
111
|
+
},
|
|
112
|
+
maxWidth: widthSizeVariant
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default generateStyle
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
export { Byline } from '../Byline/v2'
|
|
25
|
+
export type { BylineProps } from '../Byline/v2/props'
|