@instructure/ui-buttons 10.0.1-snapshot-9 → 10.0.1-snapshot-11

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [10.0.1-snapshot-9](https://github.com/instructure/instructure-ui/compare/v10.0.0...v10.0.1-snapshot-9) (2024-08-14)
6
+ ## [10.0.1-snapshot-11](https://github.com/instructure/instructure-ui/compare/v10.0.0...v10.0.1-snapshot-11) (2024-08-14)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-buttons
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-buttons",
3
- "version": "10.0.1-snapshot-9",
3
+ "version": "10.0.1-snapshot-11",
4
4
  "description": "Accessible button components",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,10 +23,10 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "10.0.1-snapshot-9",
27
- "@instructure/ui-babel-preset": "10.0.1-snapshot-9",
28
- "@instructure/ui-test-utils": "10.0.1-snapshot-9",
29
- "@instructure/ui-themes": "10.0.1-snapshot-9",
26
+ "@instructure/ui-axe-check": "10.0.1-snapshot-11",
27
+ "@instructure/ui-babel-preset": "10.0.1-snapshot-11",
28
+ "@instructure/ui-test-utils": "10.0.1-snapshot-11",
29
+ "@instructure/ui-themes": "10.0.1-snapshot-11",
30
30
  "@testing-library/jest-dom": "^6.4.6",
31
31
  "@testing-library/react": "^15.0.7",
32
32
  "@testing-library/user-event": "^14.5.2",
@@ -34,21 +34,21 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.24.5",
37
- "@instructure/console": "10.0.1-snapshot-9",
38
- "@instructure/emotion": "10.0.1-snapshot-9",
39
- "@instructure/shared-types": "10.0.1-snapshot-9",
40
- "@instructure/ui-a11y-content": "10.0.1-snapshot-9",
41
- "@instructure/ui-a11y-utils": "10.0.1-snapshot-9",
42
- "@instructure/ui-color-utils": "10.0.1-snapshot-9",
43
- "@instructure/ui-dom-utils": "10.0.1-snapshot-9",
44
- "@instructure/ui-icons": "10.0.1-snapshot-9",
45
- "@instructure/ui-position": "10.0.1-snapshot-9",
46
- "@instructure/ui-prop-types": "10.0.1-snapshot-9",
47
- "@instructure/ui-react-utils": "10.0.1-snapshot-9",
48
- "@instructure/ui-testable": "10.0.1-snapshot-9",
49
- "@instructure/ui-tooltip": "10.0.1-snapshot-9",
50
- "@instructure/ui-utils": "10.0.1-snapshot-9",
51
- "@instructure/ui-view": "10.0.1-snapshot-9",
37
+ "@instructure/console": "10.0.1-snapshot-11",
38
+ "@instructure/emotion": "10.0.1-snapshot-11",
39
+ "@instructure/shared-types": "10.0.1-snapshot-11",
40
+ "@instructure/ui-a11y-content": "10.0.1-snapshot-11",
41
+ "@instructure/ui-a11y-utils": "10.0.1-snapshot-11",
42
+ "@instructure/ui-color-utils": "10.0.1-snapshot-11",
43
+ "@instructure/ui-dom-utils": "10.0.1-snapshot-11",
44
+ "@instructure/ui-icons": "10.0.1-snapshot-11",
45
+ "@instructure/ui-position": "10.0.1-snapshot-11",
46
+ "@instructure/ui-prop-types": "10.0.1-snapshot-11",
47
+ "@instructure/ui-react-utils": "10.0.1-snapshot-11",
48
+ "@instructure/ui-testable": "10.0.1-snapshot-11",
49
+ "@instructure/ui-tooltip": "10.0.1-snapshot-11",
50
+ "@instructure/ui-utils": "10.0.1-snapshot-11",
51
+ "@instructure/ui-view": "10.0.1-snapshot-11",
52
52
  "keycode": "^2",
53
53
  "prop-types": "^15.8.1"
54
54
  },
@@ -5,23 +5,43 @@ describes: ToggleButton
5
5
  `ToggleButton` is a controlled button component used for toggling a status or setting
6
6
  between one of two states (locked/unlocked, published/unpublished, etc.).
7
7
 
8
- ```javascript
9
- ---
10
- type: example
11
- ---
12
- class Example extends React.Component {
13
- state = {
14
- locked: 'off'
15
- }
8
+ - ```javascript
9
+ class Example extends React.Component {
10
+ state = {
11
+ locked: false
12
+ }
13
+
14
+ handleLocked = (e) => {
15
+ this.setState((prevState) => ({ locked: !prevState.locked }))
16
+ }
16
17
 
17
- handleLocked = (e) => {
18
- this.setState(function(prevState) {
19
- return {locked: prevState.locked === 'on' ? 'off' : 'on'}
20
- })
18
+ render() {
19
+ const locked = this.state.locked
20
+
21
+ return (
22
+ <View as="div" padding="x-large" id="toggleContainer">
23
+ <ToggleButton
24
+ status={locked ? 'pressed' : 'unpressed'}
25
+ color={locked ? 'danger' : 'secondary'}
26
+ renderIcon={locked ? IconLockSolid : IconUnlockLine}
27
+ screenReaderLabel={locked ? 'Unlock assignment' : 'Lock assignment'}
28
+ renderTooltipContent={locked ? 'Unlock' : 'Lock'}
29
+ onClick={this.handleLocked}
30
+ />
31
+ </View>
32
+ )
33
+ }
21
34
  }
35
+ render(<Example />)
36
+ ```
37
+
38
+ - ```js
39
+ const Example = () => {
40
+ const [locked, setLocked] = useState(false)
22
41
 
23
- render () {
24
- const locked = this.state.locked === 'on'
42
+ const handleLocked = () => {
43
+ setLocked(!locked)
44
+ }
25
45
 
26
46
  return (
27
47
  <View as="div" padding="x-large" id="toggleContainer">
@@ -31,53 +51,80 @@ class Example extends React.Component {
31
51
  renderIcon={locked ? IconLockSolid : IconUnlockLine}
32
52
  screenReaderLabel={locked ? 'Unlock assignment' : 'Lock assignment'}
33
53
  renderTooltipContent={locked ? 'Unlock' : 'Lock'}
34
- onClick={this.handleLocked}
35
- mountNode={() => document.getElementById('toggleContainer')}
54
+ onClick={handleLocked}
36
55
  />
37
56
  </View>
38
57
  )
39
58
  }
40
- }
41
- render(<Example />)
42
- ```
59
+
60
+ render(<Example />)
61
+ ```
43
62
 
44
63
  ### Inverse ToggleButton
45
64
 
46
- ```javascript
47
- ---
48
- type: example
49
- ---
50
- class InverseExample extends React.Component {
51
- state = {
52
- locked: 'off'
53
- }
65
+ - ```javascript
66
+ class InverseExample extends React.Component {
67
+ state = {
68
+ locked: false
69
+ }
70
+
71
+ handleLocked = (e) => {
72
+ this.setState((prevState) => ({ locked: !prevState.locked }))
73
+ }
54
74
 
55
- handleLocked = (e) => {
56
- this.setState(function(prevState) {
57
- return {locked: prevState.locked === 'on' ? 'off' : 'on'}
58
- })
75
+ render() {
76
+ const locked = this.state.locked
77
+
78
+ return (
79
+ <View
80
+ as="div"
81
+ padding="xx-large"
82
+ background="primary-inverse"
83
+ id="inverseToggleContainer"
84
+ >
85
+ <ToggleButton
86
+ status={locked ? 'pressed' : 'unpressed'}
87
+ color="primary-inverse"
88
+ renderIcon={locked ? IconLockSolid : IconUnlockLine}
89
+ screenReaderLabel={locked ? 'Unlock assignment' : 'Lock assignment'}
90
+ renderTooltipContent={locked ? 'Unlock' : 'Lock'}
91
+ onClick={this.handleLocked}
92
+ />
93
+ </View>
94
+ )
95
+ }
59
96
  }
97
+ render(<InverseExample />)
98
+ ```
99
+
100
+ - ```js
101
+ const InverseExample = () => {
102
+ const [locked, setLocked] = useState(false)
60
103
 
61
- render () {
62
- const locked = this.state.locked === 'on'
104
+ const handleLocked = () => {
105
+ setLocked(!locked)
106
+ }
63
107
 
64
108
  return (
65
- <View as="div" padding="xx-large" background="primary-inverse" id="inverseToggleContainer">
109
+ <View
110
+ as="div"
111
+ padding="xx-large"
112
+ background="primary-inverse"
113
+ id="inverseToggleContainer"
114
+ >
66
115
  <ToggleButton
67
116
  status={locked ? 'pressed' : 'unpressed'}
68
117
  color="primary-inverse"
69
118
  renderIcon={locked ? IconLockSolid : IconUnlockLine}
70
119
  screenReaderLabel={locked ? 'Unlock assignment' : 'Lock assignment'}
71
120
  renderTooltipContent={locked ? 'Unlock' : 'Lock'}
72
- onClick={this.handleLocked}
73
- mountNode={() => document.getElementById('inverseToggleContainer')}
121
+ onClick={handleLocked}
74
122
  />
75
123
  </View>
76
124
  )
77
125
  }
78
- }
79
- render(<InverseExample />)
80
- ```
126
+ render(<InverseExample />)
127
+ ```
81
128
 
82
129
  ### Guidelines
83
130