@instructure/ui-buttons 8.8.0 → 8.8.1-snapshot.63
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/LICENSE.md +27 -0
- package/es/BaseButton/index.js +14 -135
- package/es/BaseButton/props.js +138 -0
- package/es/Button/index.js +4 -87
- package/es/Button/props.js +107 -0
- package/es/CloseButton/index.js +5 -93
- package/es/CloseButton/props.js +103 -0
- package/es/CondensedButton/index.js +4 -65
- package/es/CondensedButton/props.js +86 -0
- package/es/IconButton/index.js +4 -91
- package/es/IconButton/props.js +111 -0
- package/es/ToggleButton/index.js +2 -77
- package/es/ToggleButton/props.js +100 -0
- package/lib/BaseButton/index.js +14 -135
- package/lib/BaseButton/props.js +150 -0
- package/lib/Button/index.js +4 -87
- package/lib/Button/props.js +119 -0
- package/lib/CloseButton/index.js +5 -93
- package/lib/CloseButton/props.js +115 -0
- package/lib/CondensedButton/index.js +4 -65
- package/lib/CondensedButton/props.js +98 -0
- package/lib/IconButton/index.js +4 -91
- package/lib/IconButton/props.js +123 -0
- package/lib/ToggleButton/index.js +3 -79
- package/lib/ToggleButton/props.js +112 -0
- package/package.json +22 -21
- package/src/BaseButton/index.tsx +18 -123
- package/src/BaseButton/props.ts +192 -0
- package/src/BaseButton/styles.ts +1 -1
- package/src/BaseButton/theme.ts +1 -1
- package/src/Button/index.tsx +7 -81
- package/src/Button/props.ts +149 -0
- package/src/CloseButton/index.tsx +8 -82
- package/src/CloseButton/props.ts +137 -0
- package/src/CloseButton/styles.ts +1 -1
- package/src/CloseButton/theme.ts +1 -1
- package/src/CondensedButton/index.tsx +7 -57
- package/src/CondensedButton/props.ts +118 -0
- package/src/IconButton/index.tsx +7 -84
- package/src/IconButton/props.ts +154 -0
- package/src/ToggleButton/index.tsx +5 -68
- package/src/ToggleButton/props.ts +140 -0
- package/src/index.ts +6 -6
- package/types/BaseButton/index.d.ts +63 -117
- package/types/BaseButton/index.d.ts.map +1 -1
- package/types/BaseButton/{types.d.ts → props.d.ts} +15 -9
- package/types/BaseButton/props.d.ts.map +1 -0
- package/types/BaseButton/styles.d.ts +1 -1
- package/types/BaseButton/theme.d.ts +1 -1
- package/types/BaseButton/theme.d.ts.map +1 -1
- package/types/Button/index.d.ts +36 -73
- package/types/Button/index.d.ts.map +1 -1
- package/types/Button/{types.d.ts → props.d.ts} +12 -4
- package/types/Button/props.d.ts.map +1 -0
- package/types/CloseButton/index.d.ts +41 -75
- package/types/CloseButton/index.d.ts.map +1 -1
- package/types/CloseButton/props.d.ts +27 -0
- package/types/CloseButton/props.d.ts.map +1 -0
- package/types/CloseButton/styles.d.ts +1 -1
- package/types/CloseButton/theme.d.ts +1 -1
- package/types/CloseButton/theme.d.ts.map +1 -1
- package/types/CondensedButton/index.d.ts +28 -55
- package/types/CondensedButton/index.d.ts.map +1 -1
- package/types/CondensedButton/props.d.ts +24 -0
- package/types/CondensedButton/props.d.ts.map +1 -0
- package/types/IconButton/index.d.ts +38 -76
- package/types/IconButton/index.d.ts.map +1 -1
- package/types/IconButton/props.d.ts +29 -0
- package/types/IconButton/props.d.ts.map +1 -0
- package/types/ToggleButton/index.d.ts +34 -65
- package/types/ToggleButton/index.d.ts.map +1 -1
- package/types/ToggleButton/props.d.ts +27 -0
- package/types/ToggleButton/props.d.ts.map +1 -0
- package/types/index.d.ts +6 -6
- package/es/BaseButton/types.js +0 -1
- package/es/Button/types.js +0 -1
- package/es/CloseButton/types.js +0 -1
- package/es/CondensedButton/types.js +0 -1
- package/es/IconButton/types.js +0 -1
- package/es/ToggleButton/types.js +0 -1
- package/lib/BaseButton/types.js +0 -1
- package/lib/Button/types.js +0 -1
- package/lib/CloseButton/types.js +0 -1
- package/lib/CondensedButton/types.js +0 -1
- package/lib/IconButton/types.js +0 -1
- package/lib/ToggleButton/types.js +0 -1
- package/src/BaseButton/types.ts +0 -57
- package/src/Button/types.ts +0 -44
- package/src/CloseButton/types.ts +0 -45
- package/src/CondensedButton/types.ts +0 -40
- package/src/IconButton/types.ts +0 -45
- package/src/ToggleButton/types.ts +0 -48
- package/types/BaseButton/types.d.ts.map +0 -1
- package/types/Button/types.d.ts.map +0 -1
- package/types/CloseButton/types.d.ts +0 -22
- package/types/CloseButton/types.d.ts.map +0 -1
- package/types/CondensedButton/types.d.ts +0 -16
- package/types/CondensedButton/types.d.ts.map +0 -1
- package/types/IconButton/types.d.ts +0 -21
- package/types/IconButton/types.d.ts.map +0 -1
- package/types/ToggleButton/types.d.ts +0 -20
- package/types/ToggleButton/types.d.ts.map +0 -1
|
@@ -24,19 +24,20 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import { IconXSolid } from '@instructure/ui-icons'
|
|
30
29
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content'
|
|
31
30
|
import { testable } from '@instructure/ui-testable'
|
|
32
31
|
import { getInteraction, passthroughProps } from '@instructure/ui-react-utils'
|
|
33
32
|
|
|
34
|
-
import { withStyle, jsx
|
|
33
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
35
34
|
|
|
36
35
|
import generateStyle from './styles'
|
|
37
36
|
import generateComponentTheme from './theme'
|
|
38
37
|
import { BaseButton } from '../BaseButton'
|
|
39
|
-
|
|
38
|
+
|
|
39
|
+
import { propTypes, allowedProps } from './props'
|
|
40
|
+
import type { CloseButtonProps } from './props'
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
---
|
|
@@ -48,94 +49,19 @@ category: components
|
|
|
48
49
|
class CloseButton extends Component<CloseButtonProps> {
|
|
49
50
|
static readonly componentId = 'CloseButton'
|
|
50
51
|
|
|
51
|
-
static propTypes =
|
|
52
|
-
|
|
53
|
-
makeStyles: PropTypes.func,
|
|
54
|
-
// eslint-disable-next-line react/require-default-props
|
|
55
|
-
styles: PropTypes.object,
|
|
56
|
-
/**
|
|
57
|
-
* An accessible label for the `CloseButton` (required)
|
|
58
|
-
*/
|
|
59
|
-
screenReaderLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
60
|
-
.isRequired,
|
|
61
|
-
/**
|
|
62
|
-
* Specifies the color for the `CloseButton`.
|
|
63
|
-
*/
|
|
64
|
-
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
65
|
-
/**
|
|
66
|
-
* Specifies if interaction with the `CloseButton` is enabled, disabled, or readonly.
|
|
67
|
-
*/
|
|
68
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
69
|
-
/**
|
|
70
|
-
* Provides a reference to the `CloseButton`'s underlying html element.
|
|
71
|
-
*/
|
|
72
|
-
elementRef: PropTypes.func,
|
|
73
|
-
/**
|
|
74
|
-
* The size of the `CloseButton`
|
|
75
|
-
*/
|
|
76
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
77
|
-
/**
|
|
78
|
-
* Callback fired when the `CloseButton` is clicked.
|
|
79
|
-
*/
|
|
80
|
-
onClick: PropTypes.func,
|
|
81
|
-
/**
|
|
82
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
83
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
84
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
85
|
-
*/
|
|
86
|
-
margin: ThemeablePropTypes.spacing,
|
|
87
|
-
/**
|
|
88
|
-
* Specifies the placement of the `CloseButton`
|
|
89
|
-
*/
|
|
90
|
-
placement: PropTypes.oneOf(['start', 'end', 'static']),
|
|
91
|
-
/**
|
|
92
|
-
* Specifies the offset distance for the `CloseButton` with respect to both the top and start/end of the container.
|
|
93
|
-
* Note that for this property to have an effect, the `placement` prop must be set to either `start` or `end`. The
|
|
94
|
-
* offset will also be created with respect to a positioned parent. If it does not appear to be working, try setting
|
|
95
|
-
* the `position` of the parent container to `relative`.
|
|
96
|
-
*/
|
|
97
|
-
offset: PropTypes.oneOf(['none', 'x-small', 'small', 'medium']),
|
|
98
|
-
/**
|
|
99
|
-
* Specifies the type of the `Button`'s underlying html element.
|
|
100
|
-
*/
|
|
101
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
102
|
-
/**
|
|
103
|
-
* The element to render as the component root, `CloseButton` by default.
|
|
104
|
-
*/
|
|
105
|
-
as: PropTypes.elementType,
|
|
106
|
-
/**
|
|
107
|
-
* Specifies an href attribute for the `CloseButton`'s underlying html element.
|
|
108
|
-
*/
|
|
109
|
-
href: PropTypes.string,
|
|
110
|
-
/**
|
|
111
|
-
* Specify a mouse cursor to use when hovering over the `CloseButton`.
|
|
112
|
-
*/
|
|
113
|
-
cursor: PropTypes.string,
|
|
114
|
-
/**
|
|
115
|
-
* Specifies the tabindex of the `CloseButton`.
|
|
116
|
-
*/
|
|
117
|
-
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
118
|
-
}
|
|
119
|
-
|
|
52
|
+
static propTypes = propTypes
|
|
53
|
+
static allowedProps = allowedProps
|
|
120
54
|
static defaultProps = {
|
|
121
|
-
screenReaderLabel: undefined,
|
|
122
55
|
// @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
|
|
123
56
|
onClick: (event) => {},
|
|
124
|
-
elementRef: undefined,
|
|
125
|
-
color: undefined,
|
|
126
57
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
127
|
-
interaction: undefined,
|
|
128
|
-
disabled: undefined,
|
|
129
|
-
readOnly: undefined,
|
|
130
58
|
type: 'button',
|
|
131
59
|
placement: 'static',
|
|
132
60
|
offset: 'x-small',
|
|
133
61
|
size: 'small',
|
|
134
62
|
margin: '0',
|
|
135
63
|
as: 'button',
|
|
136
|
-
|
|
137
|
-
cursor: 'pointer',
|
|
138
|
-
tabIndex: undefined
|
|
64
|
+
cursor: 'pointer'
|
|
139
65
|
}
|
|
140
66
|
|
|
141
67
|
componentDidMount() {
|
|
@@ -177,7 +103,7 @@ class CloseButton extends Component<CloseButtonProps> {
|
|
|
177
103
|
} = this.props
|
|
178
104
|
|
|
179
105
|
return (
|
|
180
|
-
<span {...passthroughProps(props)} css={styles
|
|
106
|
+
<span {...passthroughProps(props)} css={styles?.closeButton}>
|
|
181
107
|
<BaseButton
|
|
182
108
|
renderIcon={IconXSolid}
|
|
183
109
|
elementRef={elementRef}
|
|
@@ -0,0 +1,137 @@
|
|
|
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 PropTypes from 'prop-types'
|
|
26
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
27
|
+
|
|
28
|
+
import type { Spacing, WithStyleProps } from '@instructure/emotion'
|
|
29
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
30
|
+
|
|
31
|
+
type CloseButtonOwnProps = {
|
|
32
|
+
screenReaderLabel: string | React.ReactNode
|
|
33
|
+
color?: 'primary' | 'primary-inverse'
|
|
34
|
+
interaction?: 'enabled' | 'disabled' | 'readonly'
|
|
35
|
+
elementRef?: (...args: any[]) => any
|
|
36
|
+
size?: 'small' | 'medium' | 'large'
|
|
37
|
+
onClick?: (...args: any[]) => any
|
|
38
|
+
margin?: Spacing
|
|
39
|
+
placement?: 'start' | 'end' | 'static'
|
|
40
|
+
offset?: 'none' | 'x-small' | 'small' | 'medium'
|
|
41
|
+
type?: 'button' | 'submit' | 'reset'
|
|
42
|
+
as?: AsElementType
|
|
43
|
+
href?: string
|
|
44
|
+
cursor?: string
|
|
45
|
+
tabIndex?: number | string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type PropKeys = keyof CloseButtonOwnProps
|
|
49
|
+
|
|
50
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
51
|
+
|
|
52
|
+
type CloseButtonProps = CloseButtonOwnProps & WithStyleProps
|
|
53
|
+
|
|
54
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
55
|
+
/**
|
|
56
|
+
* An accessible label for the `CloseButton` (required)
|
|
57
|
+
*/
|
|
58
|
+
screenReaderLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
|
|
59
|
+
.isRequired,
|
|
60
|
+
/**
|
|
61
|
+
* Specifies the color for the `CloseButton`.
|
|
62
|
+
*/
|
|
63
|
+
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
64
|
+
/**
|
|
65
|
+
* Specifies if interaction with the `CloseButton` is enabled, disabled, or readonly.
|
|
66
|
+
*/
|
|
67
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
68
|
+
/**
|
|
69
|
+
* Provides a reference to the `CloseButton`'s underlying html element.
|
|
70
|
+
*/
|
|
71
|
+
elementRef: PropTypes.func,
|
|
72
|
+
/**
|
|
73
|
+
* The size of the `CloseButton`
|
|
74
|
+
*/
|
|
75
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
76
|
+
/**
|
|
77
|
+
* Callback fired when the `CloseButton` is clicked.
|
|
78
|
+
*/
|
|
79
|
+
onClick: PropTypes.func,
|
|
80
|
+
/**
|
|
81
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
82
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
83
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
84
|
+
*/
|
|
85
|
+
margin: ThemeablePropTypes.spacing,
|
|
86
|
+
/**
|
|
87
|
+
* Specifies the placement of the `CloseButton`
|
|
88
|
+
*/
|
|
89
|
+
placement: PropTypes.oneOf(['start', 'end', 'static']),
|
|
90
|
+
/**
|
|
91
|
+
* Specifies the offset distance for the `CloseButton` with respect to both the top and start/end of the container.
|
|
92
|
+
* Note that for this property to have an effect, the `placement` prop must be set to either `start` or `end`. The
|
|
93
|
+
* offset will also be created with respect to a positioned parent. If it does not appear to be working, try setting
|
|
94
|
+
* the `position` of the parent container to `relative`.
|
|
95
|
+
*/
|
|
96
|
+
offset: PropTypes.oneOf(['none', 'x-small', 'small', 'medium']),
|
|
97
|
+
/**
|
|
98
|
+
* Specifies the type of the `Button`'s underlying html element.
|
|
99
|
+
*/
|
|
100
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
101
|
+
/**
|
|
102
|
+
* The element to render as the component root, `CloseButton` by default.
|
|
103
|
+
*/
|
|
104
|
+
as: PropTypes.elementType,
|
|
105
|
+
/**
|
|
106
|
+
* Specifies an href attribute for the `CloseButton`'s underlying html element.
|
|
107
|
+
*/
|
|
108
|
+
href: PropTypes.string,
|
|
109
|
+
/**
|
|
110
|
+
* Specify a mouse cursor to use when hovering over the `CloseButton`.
|
|
111
|
+
*/
|
|
112
|
+
cursor: PropTypes.string,
|
|
113
|
+
/**
|
|
114
|
+
* Specifies the tabindex of the `CloseButton`.
|
|
115
|
+
*/
|
|
116
|
+
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const allowedProps: AllowedPropKeys = [
|
|
120
|
+
'as',
|
|
121
|
+
'color',
|
|
122
|
+
'cursor',
|
|
123
|
+
'elementRef',
|
|
124
|
+
'href',
|
|
125
|
+
'interaction',
|
|
126
|
+
'margin',
|
|
127
|
+
'offset',
|
|
128
|
+
'onClick',
|
|
129
|
+
'placement',
|
|
130
|
+
'screenReaderLabel',
|
|
131
|
+
'size',
|
|
132
|
+
'tabIndex',
|
|
133
|
+
'type'
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
export type { CloseButtonProps }
|
|
137
|
+
export { propTypes, allowedProps }
|
package/src/CloseButton/theme.ts
CHANGED
|
@@ -23,16 +23,17 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React, { Component } from 'react'
|
|
26
|
-
import PropTypes from 'prop-types'
|
|
27
26
|
|
|
28
27
|
import { testable } from '@instructure/ui-testable'
|
|
29
28
|
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
30
29
|
|
|
31
|
-
import { withStyle
|
|
30
|
+
import { withStyle } from '@instructure/emotion'
|
|
32
31
|
|
|
33
32
|
import generateComponentTheme from './theme'
|
|
34
33
|
import { BaseButton } from '../BaseButton'
|
|
35
|
-
|
|
34
|
+
|
|
35
|
+
import { propTypes, allowedProps } from './props'
|
|
36
|
+
import type { CondensedButtonProps } from './props'
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
---
|
|
@@ -45,56 +46,8 @@ category: components
|
|
|
45
46
|
class CondensedButton extends Component<CondensedButtonProps> {
|
|
46
47
|
static readonly componentId = 'CondensedButton'
|
|
47
48
|
|
|
48
|
-
static propTypes =
|
|
49
|
-
|
|
50
|
-
* Specifies the `CondensedButton` children.
|
|
51
|
-
*/
|
|
52
|
-
children: PropTypes.node,
|
|
53
|
-
/**
|
|
54
|
-
* Specifies the type of the `CondensedButton`'s underlying html element.
|
|
55
|
-
*/
|
|
56
|
-
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
57
|
-
/**
|
|
58
|
-
* The size of the `CondensedButton`
|
|
59
|
-
*/
|
|
60
|
-
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
61
|
-
/**
|
|
62
|
-
* Provides a reference to the `CondensedButton`'s underlying html element.
|
|
63
|
-
*/
|
|
64
|
-
elementRef: PropTypes.func,
|
|
65
|
-
/**
|
|
66
|
-
* The element to render as the component root, `button` by default.
|
|
67
|
-
*/
|
|
68
|
-
as: PropTypes.elementType,
|
|
69
|
-
/**
|
|
70
|
-
* Specifies if interaction with the `CondensedButton` is enabled, disabled, or readonly.
|
|
71
|
-
*/
|
|
72
|
-
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
73
|
-
/**
|
|
74
|
-
* Specifies the color for the `CondensedButton`.
|
|
75
|
-
*/
|
|
76
|
-
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
77
|
-
/**
|
|
78
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
79
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
80
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
81
|
-
*/
|
|
82
|
-
margin: ThemeablePropTypes.spacing,
|
|
83
|
-
/**
|
|
84
|
-
* Specify a mouse cursor to use when hovering over the button.
|
|
85
|
-
* The `pointer` cursor is used by default.
|
|
86
|
-
*/
|
|
87
|
-
cursor: PropTypes.string,
|
|
88
|
-
/**
|
|
89
|
-
* Specifies an href attribute for the `CondensedButton`'s underlying html element.
|
|
90
|
-
*/
|
|
91
|
-
href: PropTypes.string,
|
|
92
|
-
/**
|
|
93
|
-
* An icon, or function that returns an icon.
|
|
94
|
-
*/
|
|
95
|
-
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
96
|
-
}
|
|
97
|
-
|
|
49
|
+
static propTypes = propTypes
|
|
50
|
+
static allowedProps = allowedProps
|
|
98
51
|
static defaultProps = {
|
|
99
52
|
children: null,
|
|
100
53
|
type: 'button',
|
|
@@ -103,12 +56,9 @@ class CondensedButton extends Component<CondensedButtonProps> {
|
|
|
103
56
|
elementRef: (el) => {},
|
|
104
57
|
as: 'button',
|
|
105
58
|
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
106
|
-
interaction: undefined,
|
|
107
59
|
color: 'primary',
|
|
108
60
|
margin: '0',
|
|
109
|
-
cursor: 'pointer'
|
|
110
|
-
href: undefined,
|
|
111
|
-
renderIcon: undefined
|
|
61
|
+
cursor: 'pointer'
|
|
112
62
|
}
|
|
113
63
|
|
|
114
64
|
_baseButton = null
|
|
@@ -0,0 +1,118 @@
|
|
|
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 PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
|
|
30
|
+
import type { Spacing } from '@instructure/emotion'
|
|
31
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
32
|
+
|
|
33
|
+
type CondensedButtonOwnProps = {
|
|
34
|
+
children?: React.ReactNode
|
|
35
|
+
type?: 'button' | 'submit' | 'reset'
|
|
36
|
+
size?: 'small' | 'medium' | 'large'
|
|
37
|
+
elementRef?: (...args: any[]) => any
|
|
38
|
+
as?: AsElementType
|
|
39
|
+
interaction?: 'enabled' | 'disabled' | 'readonly'
|
|
40
|
+
color?: 'primary' | 'primary-inverse'
|
|
41
|
+
margin?: Spacing
|
|
42
|
+
cursor?: string
|
|
43
|
+
href?: string
|
|
44
|
+
renderIcon?: React.ReactNode | ((...args: any[]) => any)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type PropKeys = keyof CondensedButtonOwnProps
|
|
48
|
+
|
|
49
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
50
|
+
|
|
51
|
+
type CondensedButtonProps = CondensedButtonOwnProps
|
|
52
|
+
|
|
53
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
54
|
+
/**
|
|
55
|
+
* Specifies the `CondensedButton` children.
|
|
56
|
+
*/
|
|
57
|
+
children: PropTypes.node,
|
|
58
|
+
/**
|
|
59
|
+
* Specifies the type of the `CondensedButton`'s underlying html element.
|
|
60
|
+
*/
|
|
61
|
+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
|
|
62
|
+
/**
|
|
63
|
+
* The size of the `CondensedButton`
|
|
64
|
+
*/
|
|
65
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
66
|
+
/**
|
|
67
|
+
* Provides a reference to the `CondensedButton`'s underlying html element.
|
|
68
|
+
*/
|
|
69
|
+
elementRef: PropTypes.func,
|
|
70
|
+
/**
|
|
71
|
+
* The element to render as the component root, `button` by default.
|
|
72
|
+
*/
|
|
73
|
+
as: PropTypes.elementType,
|
|
74
|
+
/**
|
|
75
|
+
* Specifies if interaction with the `CondensedButton` is enabled, disabled, or readonly.
|
|
76
|
+
*/
|
|
77
|
+
interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
|
|
78
|
+
/**
|
|
79
|
+
* Specifies the color for the `CondensedButton`.
|
|
80
|
+
*/
|
|
81
|
+
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
82
|
+
/**
|
|
83
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
84
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
85
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
86
|
+
*/
|
|
87
|
+
margin: ThemeablePropTypes.spacing,
|
|
88
|
+
/**
|
|
89
|
+
* Specify a mouse cursor to use when hovering over the button.
|
|
90
|
+
* The `pointer` cursor is used by default.
|
|
91
|
+
*/
|
|
92
|
+
cursor: PropTypes.string,
|
|
93
|
+
/**
|
|
94
|
+
* Specifies an href attribute for the `CondensedButton`'s underlying html element.
|
|
95
|
+
*/
|
|
96
|
+
href: PropTypes.string,
|
|
97
|
+
/**
|
|
98
|
+
* An icon, or function that returns an icon.
|
|
99
|
+
*/
|
|
100
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const allowedProps: AllowedPropKeys = [
|
|
104
|
+
'as',
|
|
105
|
+
'children',
|
|
106
|
+
'color',
|
|
107
|
+
'cursor',
|
|
108
|
+
'elementRef',
|
|
109
|
+
'href',
|
|
110
|
+
'interaction',
|
|
111
|
+
'margin',
|
|
112
|
+
'renderIcon',
|
|
113
|
+
'size',
|
|
114
|
+
'type'
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
export type { CondensedButtonProps }
|
|
118
|
+
export { propTypes, allowedProps }
|