@instructure/ui-motion 11.0.2-snapshot-5 → 11.0.2-snapshot-7

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
- ## [11.0.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v11.0.1...v11.0.2-snapshot-5) (2025-10-30)
6
+ ## [11.0.2-snapshot-7](https://github.com/instructure/instructure-ui/compare/v11.0.1...v11.0.2-snapshot-7) (2025-11-03)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-motion
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-motion",
3
- "version": "11.0.2-snapshot-5",
3
+ "version": "11.0.2-snapshot-7",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,19 +23,19 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "11.0.2-snapshot-5",
27
- "@instructure/ui-themes": "11.0.2-snapshot-5",
26
+ "@instructure/ui-babel-preset": "11.0.2-snapshot-7",
27
+ "@instructure/ui-themes": "11.0.2-snapshot-7",
28
28
  "@testing-library/jest-dom": "^6.6.3",
29
29
  "@testing-library/react": "15.0.7",
30
30
  "vitest": "^3.2.2"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.27.6",
34
- "@instructure/emotion": "11.0.2-snapshot-5",
35
- "@instructure/shared-types": "11.0.2-snapshot-5",
36
- "@instructure/ui-dom-utils": "11.0.2-snapshot-5",
37
- "@instructure/ui-react-utils": "11.0.2-snapshot-5",
38
- "@instructure/ui-utils": "11.0.2-snapshot-5"
34
+ "@instructure/emotion": "11.0.2-snapshot-7",
35
+ "@instructure/shared-types": "11.0.2-snapshot-7",
36
+ "@instructure/ui-dom-utils": "11.0.2-snapshot-7",
37
+ "@instructure/ui-react-utils": "11.0.2-snapshot-7",
38
+ "@instructure/ui-utils": "11.0.2-snapshot-7"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": ">=18 <=19"
@@ -2,47 +2,43 @@
2
2
  describes: Transition
3
3
  ---
4
4
 
5
- The `Transition` wrapper helps you easily transition elements in and out of
6
- your UI. The component defaults to the `fade` opacity transition.
5
+ The `Transition` wrapper helps you easily transition elements in and out of your UI. The component defaults to the `fade` opacity transition.
6
+
7
+ > This component uses `setTimeout()` to fire events when the animations end (the duration is set in the theme).
7
8
 
8
9
  ```js
9
10
  ---
10
11
  type: example
11
12
  ---
12
- class Example extends React.Component {
13
- constructor (props) {
14
- super(props)
15
- this.state = {
16
- in: true
17
- }
18
- }
13
+ const Example = () => {
14
+ const [isIn, setIsIn] = useState(true)
19
15
 
20
- handleButtonClick = () => {
21
- this.setState((state) => {
22
- return {
23
- in: !state.in
24
- }
25
- })
26
- };
16
+ const handleButtonClick = () => {
17
+ setIsIn((prevIsIn) => !prevIsIn)
18
+ }
27
19
 
28
- render () {
29
- return (
20
+ return (
21
+ <div>
30
22
  <div>
31
- <div>
32
- <Button margin="small 0" size="small" onClick={this.handleButtonClick}>
33
- <div aria-live="polite">Fade {this.state.in ? 'Out' : 'In'}</div>
34
- </Button>
35
- </div>
36
- <Transition
37
- transitionOnMount
38
- in={this.state.in}
39
- type="fade"
40
- >
41
- <Avatar name="Fade" />
42
- </Transition>
23
+ <Button margin="small 0" size="small" onClick={handleButtonClick}>
24
+ <div aria-live="polite">Fade {isIn ? 'Out' : 'In'}</div>
25
+ </Button>
43
26
  </div>
44
- )
45
- }
27
+ <Transition
28
+ onEnter={()=>console.log('onEnter')}
29
+ onEntered={()=>console.log('onEntered')}
30
+ onEntering={()=>console.log('onEntering')}
31
+ onExit={()=>console.log('onExit')}
32
+ onExited={()=>console.log('onExited')}
33
+ onExiting={()=>console.log('onExiting')}
34
+ onTransition={(to, from)=>console.log('onTransition', to, from)}
35
+ in={isIn}
36
+ type="fade"
37
+ >
38
+ <Avatar name="Fade" />
39
+ </Transition>
40
+ </div>
41
+ )
46
42
  }
47
43
 
48
44
  render(<Example />)
@@ -54,41 +50,30 @@ render(<Example />)
54
50
  ---
55
51
  type: example
56
52
  ---
57
- class Example extends React.Component {
58
- constructor (props) {
59
- super(props)
60
- this.state = {
61
- in: true
62
- }
63
- }
53
+ const Example = () => {
54
+ const [isIn, setIsIn] = useState(true)
64
55
 
65
- handleButtonClick = () => {
66
- this.setState((state) => {
67
- return {
68
- in: !state.in
69
- }
70
- })
71
- };
56
+ const handleButtonClick = () => {
57
+ setIsIn((prevIsIn) => !prevIsIn)
58
+ }
72
59
 
73
- render () {
74
- return (
60
+ return (
61
+ <div>
75
62
  <div>
76
- <div>
77
- <Button margin="small 0" size="small" onClick={this.handleButtonClick}>
78
- <div aria-live="polite">{this.state.in ? 'Collapse' : 'Expand'}</div>
79
- </Button>
80
- </div>
81
- <Transition
82
- transitionOnMount
83
- unmountOnExit
84
- in={this.state.in}
85
- type="scale"
86
- >
87
- <Avatar name="Collapse" />
88
- </Transition>
63
+ <Button margin="small 0" size="small" onClick={handleButtonClick}>
64
+ <div aria-live="polite">{isIn ? 'Collapse' : 'Expand'}</div>
65
+ </Button>
89
66
  </div>
90
- )
91
- }
67
+ <Transition
68
+ transitionOnMount
69
+ unmountOnExit
70
+ in={isIn}
71
+ type="scale"
72
+ >
73
+ <Avatar name="Collapse" />
74
+ </Transition>
75
+ </div>
76
+ )
92
77
  }
93
78
 
94
79
  render(<Example />)
@@ -102,34 +87,21 @@ internationalized for right to left (rtl) languages. The following example uses
102
87
  ---
103
88
  type: example
104
89
  ---
105
- class Example extends React.Component {
106
-
107
- static contextType = TextDirectionContext
90
+ const Example = () => {
91
+ const textDirection = useContext(TextDirectionContext)
92
+ const [direction, setDirection] = useState('left')
93
+ const [isIn, setIsIn] = useState(true)
94
+
95
+ const handleDirectionChange = (e, value) => {
96
+ setDirection(value)
97
+ setIsIn(true)
98
+ }
108
99
 
109
- constructor (props) {
110
- super(props)
111
- this.state = {
112
- direction: 'left',
113
- in: true
114
- }
100
+ const handleButtonClick = () => {
101
+ setIsIn((prevIsIn) => !prevIsIn)
115
102
  }
116
103
 
117
- handleDirectionChange = (e, value) => {
118
- this.setState({
119
- direction: value,
120
- in: true
121
- })
122
- };
123
-
124
- handleButtonClick = () => {
125
- this.setState((state) => {
126
- return {
127
- in: !state.in
128
- }
129
- })
130
- };
131
-
132
- mirrorDirection (direction) {
104
+ const mirrorDirection = (direction) => {
133
105
  const mirror = {
134
106
  left: 'right',
135
107
  right: 'left',
@@ -137,52 +109,51 @@ class Example extends React.Component {
137
109
  down: 'down'
138
110
  }
139
111
  return mirror[direction]
140
- };
141
-
142
- render () {
143
- const rtl = this.context === 'rtl'
144
- const direction = rtl ? this.mirrorDirection(this.state.direction) : this.state.direction
145
- const directionVariants = [
146
- {value: 'left', label: 'Start'},
147
- {value: 'right', label: 'End'},
148
- {value: 'down', label: 'Down'},
149
- {value: 'up', label: 'Up'}
150
- ]
151
- return (
112
+ }
113
+
114
+ const rtl = textDirection === 'rtl'
115
+ const finalDirection = rtl ? mirrorDirection(direction) : direction
116
+ const directionVariants = [
117
+ {value: 'left', label: 'Start'},
118
+ {value: 'right', label: 'End'},
119
+ {value: 'down', label: 'Down'},
120
+ {value: 'up', label: 'Up'}
121
+ ]
122
+
123
+ return (
124
+ <div>
152
125
  <div>
153
- <div>
154
- <RadioInputGroup
155
- onChange={this.handleDirectionChange}
156
- name="slideExample"
157
- description={<ScreenReaderContent>Select a direction</ScreenReaderContent>}
158
- value={direction}
159
- variant="toggle"
160
- >
161
- {directionVariants.map(dir => <RadioInput key={dir.value} value={dir.value} label={dir.label} />)}
162
- </RadioInputGroup>
163
- <Button size="small" margin="medium none small" onClick={this.handleButtonClick}>
164
- <div aria-live="polite">Slide {this.state.in ? 'Out' : 'In'}</div>
165
- </Button>
166
- </div>
167
- <div style={{
168
- position: 'relative',
169
- overflow: 'hidden',
170
- height: '15rem',
171
- display: 'flex',
172
- justifyContent: (this.state.direction === 'right') ? 'flex-end' : 'flex-start'
173
- }}>
174
- <Transition
175
- transitionOnMount
176
- unmountOnExit
177
- in={this.state.in}
178
- type={`slide-${direction}`}
179
- >
180
- <Avatar name="Slide" />
181
- </Transition>
182
- </div>
126
+ <RadioInputGroup
127
+ onChange={handleDirectionChange}
128
+ name="slideExample"
129
+ description={<ScreenReaderContent>Select a direction</ScreenReaderContent>}
130
+ value={finalDirection}
131
+ variant="toggle"
132
+ >
133
+ {directionVariants.map(dir => <RadioInput key={dir.value} value={dir.value} label={dir.label} />)}
134
+ </RadioInputGroup>
135
+ <Button size="small" margin="medium none small" onClick={handleButtonClick}>
136
+ <div aria-live="polite">Slide {isIn ? 'Out' : 'In'}</div>
137
+ </Button>
183
138
  </div>
184
- )
185
- }
139
+ <div style={{
140
+ position: 'relative',
141
+ overflow: 'hidden',
142
+ height: '15rem',
143
+ display: 'flex',
144
+ justifyContent: (direction === 'right') ? 'flex-end' : 'flex-start'
145
+ }}>
146
+ <Transition
147
+ transitionOnMount
148
+ unmountOnExit
149
+ in={isIn}
150
+ type={`slide-${finalDirection}`}
151
+ >
152
+ <Avatar name="Slide" />
153
+ </Transition>
154
+ </div>
155
+ </div>
156
+ )
186
157
  }
187
158
 
188
159
  render(<Example />)