@instructure/ui-options 8.19.1-snapshot.8 → 8.20.0

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.
@@ -24,6 +24,9 @@ example: true
24
24
  <Options.Item variant="disabled">
25
25
  Disabled option
26
26
  </Options.Item>
27
+ <Options.Item variant="highlighted-disabled">
28
+ Highlighted disabled option
29
+ </Options.Item>
27
30
  </Options>
28
31
  </View>
29
32
  ```
@@ -372,3 +375,61 @@ class Example extends React.Component {
372
375
 
373
376
  render(<Example />)
374
377
  ```
378
+
379
+ Providing a `href` prop will render the option as `<a>` link element.
380
+
381
+ **WARNING!** Since `Options` is a view-only component, you have to make sure it is accessible, and if set the variant to disabled, disable the links as well!
382
+
383
+ ```js
384
+ ---
385
+ render: false
386
+ example: true
387
+ ---
388
+ class Example extends React.Component {
389
+ constructor(props) {
390
+ super(props)
391
+
392
+ this.state = {
393
+ highlighted: -1
394
+ }
395
+ }
396
+
397
+ handleMouseOver = (index) => {
398
+ this.setState({ highlighted: index })
399
+ }
400
+
401
+ render() {
402
+ return (
403
+ <View display="block" width="300px">
404
+ <Options onMouseOut={(e) => this.setState({ highlighted: -1 })}>
405
+ <Options.Item
406
+ onMouseOver={(e) => this.handleMouseOver(1)}
407
+ variant={this.state.highlighted === 1 ? 'highlighted' : 'default'}
408
+ href="/"
409
+ >
410
+ Link one
411
+ </Options.Item>
412
+ <Options.Item
413
+ onMouseOver={(e) => this.handleMouseOver(2)}
414
+ variant={this.state.highlighted === 2 ? 'highlighted' : 'default'}
415
+ href="/"
416
+ >
417
+ Link two
418
+ </Options.Item>
419
+ <Options.Item
420
+ onMouseOver={(e) => this.handleMouseOver(3)}
421
+ variant={this.state.highlighted === 3 ? 'highlighted' : 'default'}
422
+ variant="disabled"
423
+ onClick={(e) => { e.preventDefault() }}
424
+ href="/"
425
+ >
426
+ Link three
427
+ </Options.Item>
428
+ </Options>
429
+ </View>
430
+ )
431
+ }
432
+ }
433
+
434
+ render(<Example />)
435
+ ```
@@ -134,7 +134,7 @@ class Options extends Component<OptionsProps> {
134
134
  return this.renderSubList(child)
135
135
  }
136
136
  if (matchComponentTypes(child, ['Item', 'Separator'])) {
137
- return safeCloneElement(child, { as: this.childAs })
137
+ return safeCloneElement(child, { as: this.childAs || child.props.as })
138
138
  }
139
139
  return undefined
140
140
  })
@@ -161,7 +161,13 @@ class Options extends Component<OptionsProps> {
161
161
  margin="none"
162
162
  padding="none"
163
163
  background="primary"
164
- aria-labelledby={renderLabel ? this._labelId : undefined}
164
+ aria-labelledby={
165
+ renderLabel
166
+ ? this._labelId
167
+ : this.props['aria-labelledby']
168
+ ? this.props['aria-labelledby']
169
+ : undefined
170
+ }
165
171
  >
166
172
  {this.renderChildren()}
167
173
  </View>