@instructure/ui-billboard 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 +33 -280
- package/es/Billboard/{index.js → v1/index.js} +3 -3
- package/es/Billboard/v2/index.js +188 -0
- package/es/Billboard/v2/props.js +26 -0
- package/es/Billboard/v2/styles.js +169 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -2
- package/lib/Billboard/{index.js → v1/index.js} +7 -7
- package/lib/Billboard/v2/index.js +195 -0
- package/lib/Billboard/v2/props.js +31 -0
- package/lib/Billboard/v2/styles.js +175 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +41 -19
- package/src/Billboard/{index.tsx → v1/index.tsx} +4 -4
- package/src/Billboard/{props.ts → v1/props.ts} +1 -1
- package/src/Billboard/v2/README.md +95 -0
- package/src/Billboard/v2/index.tsx +202 -0
- package/src/Billboard/v2/props.ts +128 -0
- package/src/Billboard/v2/styles.ts +158 -0
- package/src/exports/a.ts +25 -0
- package/src/exports/b.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Billboard/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/Billboard/v1/index.d.ts.map +1 -0
- package/types/Billboard/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/Billboard/v1/props.d.ts.map +1 -0
- package/types/Billboard/v1/styles.d.ts.map +1 -0
- package/types/Billboard/v1/theme.d.ts.map +1 -0
- package/types/Billboard/v2/index.d.ts +58 -0
- package/types/Billboard/v2/index.d.ts.map +1 -0
- package/types/Billboard/v2/props.d.ts +74 -0
- package/types/Billboard/v2/props.d.ts.map +1 -0
- package/types/Billboard/v2/styles.d.ts +15 -0
- package/types/Billboard/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/Billboard/index.d.ts.map +0 -1
- package/types/Billboard/props.d.ts.map +0 -1
- package/types/Billboard/styles.d.ts.map +0 -1
- package/types/Billboard/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/Billboard/{props.js → v1/props.js} +0 -0
- /package/es/Billboard/{styles.js → v1/styles.js} +0 -0
- /package/es/Billboard/{theme.js → v1/theme.js} +0 -0
- /package/lib/Billboard/{props.js → v1/props.js} +0 -0
- /package/lib/Billboard/{styles.js → v1/styles.js} +0 -0
- /package/lib/Billboard/{theme.js → v1/theme.js} +0 -0
- /package/src/Billboard/{README.md → v1/README.md} +0 -0
- /package/src/Billboard/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Billboard/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Billboard/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Billboard/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
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 {
|
|
26
|
+
Spacing,
|
|
27
|
+
WithStyleProps,
|
|
28
|
+
ComponentStyle
|
|
29
|
+
} from '@instructure/emotion'
|
|
30
|
+
import type {
|
|
31
|
+
AsElementType,
|
|
32
|
+
BillboardTheme,
|
|
33
|
+
OtherHTMLAttributes
|
|
34
|
+
} from '@instructure/shared-types'
|
|
35
|
+
import type { ViewProps } from '@instructure/ui-view/latest'
|
|
36
|
+
import { MouseEvent } from 'react'
|
|
37
|
+
import { Renderable } from '@instructure/shared-types'
|
|
38
|
+
type HeroIconSize = 'medium' | 'x-large' | 'large'
|
|
39
|
+
type BillboardOwnProps = {
|
|
40
|
+
/**
|
|
41
|
+
* Provide an <Img> component or Instructure Icon for the hero image
|
|
42
|
+
*/
|
|
43
|
+
hero?: React.ReactElement | ((iconSize?: HeroIconSize) => React.ReactElement)
|
|
44
|
+
/**
|
|
45
|
+
* If you're using an icon, this prop will size it. Also sets the font-size
|
|
46
|
+
* of the headline and message.
|
|
47
|
+
*/
|
|
48
|
+
size?: 'small' | 'medium' | 'large'
|
|
49
|
+
/**
|
|
50
|
+
* the element type to render as
|
|
51
|
+
*/
|
|
52
|
+
as?: AsElementType
|
|
53
|
+
/**
|
|
54
|
+
* provides a reference to the underlying html root element
|
|
55
|
+
*/
|
|
56
|
+
elementRef?: (element: Element | null) => void
|
|
57
|
+
/**
|
|
58
|
+
* The headline for the Billboard. Is styled as an h1 element by default
|
|
59
|
+
*/
|
|
60
|
+
heading?: string
|
|
61
|
+
/**
|
|
62
|
+
* Choose the appropriately semantic tag for the heading
|
|
63
|
+
*/
|
|
64
|
+
headingAs?: 'h1' | 'h2' | 'h3' | 'span'
|
|
65
|
+
/**
|
|
66
|
+
* Choose the font-size for the heading (see the Heading component)
|
|
67
|
+
*/
|
|
68
|
+
headingLevel?: 'h1' | 'h2' | 'h3' | 'h4'
|
|
69
|
+
/**
|
|
70
|
+
* Instructions or information for the Billboard. Note: you should not pass
|
|
71
|
+
* interactive content to this prop if you are also providing an `href` or
|
|
72
|
+
* `onClick`. That would cause the Billboard to render as a button or link
|
|
73
|
+
* and would result in nested interactive content.
|
|
74
|
+
*/
|
|
75
|
+
message?: Renderable
|
|
76
|
+
/**
|
|
77
|
+
* If you add an onClick prop, the Billboard renders as a clickable button
|
|
78
|
+
*/
|
|
79
|
+
onClick?: (e: MouseEvent<ViewProps>) => void
|
|
80
|
+
/**
|
|
81
|
+
* If `href` is provided, Billboard will render as a link
|
|
82
|
+
*/
|
|
83
|
+
href?: string
|
|
84
|
+
/**
|
|
85
|
+
* Whether or not to disable the billboard
|
|
86
|
+
*/
|
|
87
|
+
disabled?: boolean
|
|
88
|
+
/**
|
|
89
|
+
* Works just like disabled but keeps the same styles as if it were active
|
|
90
|
+
*/
|
|
91
|
+
readOnly?: boolean
|
|
92
|
+
/**
|
|
93
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
94
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
95
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
96
|
+
*/
|
|
97
|
+
margin?: Spacing
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type PropKeys = keyof BillboardOwnProps
|
|
101
|
+
|
|
102
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
103
|
+
|
|
104
|
+
type BillboardProps = BillboardOwnProps &
|
|
105
|
+
WithStyleProps<BillboardTheme, BillboardStyle> &
|
|
106
|
+
OtherHTMLAttributes<BillboardOwnProps>
|
|
107
|
+
|
|
108
|
+
type BillboardStyle = ComponentStyle<
|
|
109
|
+
'billboard' | 'content' | 'hero' | 'heading' | 'message'
|
|
110
|
+
>
|
|
111
|
+
const allowedProps: AllowedPropKeys = [
|
|
112
|
+
'hero',
|
|
113
|
+
'size',
|
|
114
|
+
'as',
|
|
115
|
+
'elementRef',
|
|
116
|
+
'heading',
|
|
117
|
+
'headingAs',
|
|
118
|
+
'headingLevel',
|
|
119
|
+
'message',
|
|
120
|
+
'onClick',
|
|
121
|
+
'href',
|
|
122
|
+
'disabled',
|
|
123
|
+
'readOnly',
|
|
124
|
+
'margin'
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
export type { BillboardProps, BillboardStyle, HeroIconSize }
|
|
128
|
+
export { allowedProps }
|
|
@@ -0,0 +1,158 @@
|
|
|
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 { BillboardProps, BillboardStyle } from './props'
|
|
26
|
+
import type { NewComponentTypes } from '@instructure/ui-themes'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ---
|
|
30
|
+
* private: true
|
|
31
|
+
* ---
|
|
32
|
+
* Generates the style object from the theme and provided additional information
|
|
33
|
+
* @param {Object} componentTheme The theme variable object.
|
|
34
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
35
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
36
|
+
* @return {Object} The final style object, which will be used in the component
|
|
37
|
+
*/
|
|
38
|
+
const generateStyle = (
|
|
39
|
+
componentTheme: NewComponentTypes['Billboard'],
|
|
40
|
+
props: BillboardProps
|
|
41
|
+
): BillboardStyle => {
|
|
42
|
+
const { size, href, onClick, disabled, hero, heading } = props
|
|
43
|
+
|
|
44
|
+
const clickable = href || onClick
|
|
45
|
+
|
|
46
|
+
const sizeVariants = {
|
|
47
|
+
small: {
|
|
48
|
+
billboard: { padding: componentTheme.paddingSmall },
|
|
49
|
+
hero: { fontSize: '3rem' },
|
|
50
|
+
message: { fontSize: componentTheme.messageFontSizeSmall },
|
|
51
|
+
heading: { ...(hero && { margin: `${componentTheme.mediumMargin} 0 0` }) }
|
|
52
|
+
},
|
|
53
|
+
medium: {
|
|
54
|
+
billboard: { padding: componentTheme.paddingMedium },
|
|
55
|
+
hero: { fontSize: '5rem' },
|
|
56
|
+
message: { fontSize: componentTheme.messageFontSizeMedium },
|
|
57
|
+
heading: {}
|
|
58
|
+
},
|
|
59
|
+
large: {
|
|
60
|
+
billboard: { padding: componentTheme.paddingLarge },
|
|
61
|
+
hero: { fontSize: '10rem' },
|
|
62
|
+
message: { fontSize: componentTheme.messageFontSizeLarge },
|
|
63
|
+
heading: {}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const clickableVariants = clickable
|
|
68
|
+
? {
|
|
69
|
+
appearance: 'none',
|
|
70
|
+
boxSizing: 'border-box',
|
|
71
|
+
cursor: 'pointer',
|
|
72
|
+
userSelect: 'none',
|
|
73
|
+
touchAction: 'manipulation',
|
|
74
|
+
width: '100%',
|
|
75
|
+
margin: '0',
|
|
76
|
+
border: `${componentTheme.buttonBorderWidth} ${componentTheme.buttonBorderStyle} transparent`,
|
|
77
|
+
borderRadius: componentTheme.buttonBorderRadius,
|
|
78
|
+
background: componentTheme.backgroundColor,
|
|
79
|
+
textDecoration: 'none',
|
|
80
|
+
|
|
81
|
+
'&:hover': { borderStyle: componentTheme.buttonHoverBorderStyle },
|
|
82
|
+
|
|
83
|
+
'&:hover, &:focus': {
|
|
84
|
+
textDecoration: 'none',
|
|
85
|
+
outline: 'none',
|
|
86
|
+
borderColor: componentTheme.messageColorClickable
|
|
87
|
+
},
|
|
88
|
+
'&:active': {
|
|
89
|
+
background: componentTheme.clickableActiveBg,
|
|
90
|
+
borderColor: componentTheme.messageColorClickable,
|
|
91
|
+
|
|
92
|
+
'& [class$=-billboard__hero], & [class$=-billboard__message]': {
|
|
93
|
+
color: componentTheme.clickableActiveText
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
: {
|
|
98
|
+
backgroundColor: componentTheme.backgroundColor
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
billboard: {
|
|
103
|
+
label: 'billboard',
|
|
104
|
+
boxSizing: 'border-box',
|
|
105
|
+
position: 'relative',
|
|
106
|
+
fontFamily: componentTheme.fontFamily,
|
|
107
|
+
marginLeft: 'auto',
|
|
108
|
+
marginRight: 'auto',
|
|
109
|
+
textAlign: 'center',
|
|
110
|
+
display: 'block',
|
|
111
|
+
...sizeVariants[size!].billboard,
|
|
112
|
+
...clickableVariants,
|
|
113
|
+
|
|
114
|
+
...(disabled && {
|
|
115
|
+
cursor: 'not-allowed',
|
|
116
|
+
pointerEvents: 'none',
|
|
117
|
+
opacity: 0.5
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
content: {
|
|
121
|
+
label: 'billboard__content',
|
|
122
|
+
display: 'block'
|
|
123
|
+
},
|
|
124
|
+
hero: {
|
|
125
|
+
label: 'billboard__hero',
|
|
126
|
+
display: 'block',
|
|
127
|
+
...sizeVariants[size!].hero,
|
|
128
|
+
|
|
129
|
+
'& > img, & > svg': {
|
|
130
|
+
maxWidth: '100%',
|
|
131
|
+
display: 'block',
|
|
132
|
+
margin: '0 auto'
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
'& > img': { height: 'auto' }
|
|
136
|
+
},
|
|
137
|
+
heading: {
|
|
138
|
+
label: 'billboard__heading',
|
|
139
|
+
display: 'block',
|
|
140
|
+
...(hero && { margin: `${componentTheme.largeMargin} 0 0` }),
|
|
141
|
+
...sizeVariants[size!].heading
|
|
142
|
+
},
|
|
143
|
+
message: {
|
|
144
|
+
label: 'billboard__message',
|
|
145
|
+
display: 'block',
|
|
146
|
+
color: clickable
|
|
147
|
+
? componentTheme.messageColorClickable
|
|
148
|
+
: componentTheme.messageColor,
|
|
149
|
+
|
|
150
|
+
...((hero || heading) && {
|
|
151
|
+
margin: `${componentTheme.mediumMargin} 0 0`
|
|
152
|
+
}),
|
|
153
|
+
...sizeVariants[size!].message
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export default generateStyle
|
package/src/exports/a.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 { Billboard } from '../Billboard/v1'
|
|
25
|
+
export type { BillboardProps } from '../Billboard/v1/props'
|
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 { Billboard } from '../Billboard/v2'
|
|
25
|
+
export type { BillboardProps } from '../Billboard/v2/props'
|