2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2019-05-13 19:05:25 +00:00
|
|
|
/**
|
|
|
|
* @module Chevron
|
|
|
|
* `Chevron` components render `Icon` with one of the `chevron-` glyphs.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* ```js
|
|
|
|
* <Chevron @direction="up" />
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* @param [direction="right"] {String} - the direction the chevron icon points. Accepted values are
|
|
|
|
* "right", "down", "left", "up".
|
|
|
|
* @param [isButton=false] {String} - if true, adjusts the CSS classes to push the icon closer to the right of a button.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { assert } from '@ember/debug';
|
|
|
|
|
|
|
|
import layout from '../templates/components/chevron';
|
|
|
|
|
|
|
|
const DIRECTIONS = ['right', 'left', 'up', 'down'];
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
tagName: '',
|
|
|
|
layout,
|
|
|
|
direction: 'right',
|
|
|
|
isButton: false,
|
2021-12-17 03:44:29 +00:00
|
|
|
glyph: computed('direction', function () {
|
2022-11-09 23:15:31 +00:00
|
|
|
const { direction } = this;
|
2019-05-13 19:05:25 +00:00
|
|
|
assert(
|
|
|
|
`The direction property of ${this.toString()} must be one of the following: ${DIRECTIONS.join(', ')}`,
|
|
|
|
DIRECTIONS.includes(direction)
|
|
|
|
);
|
|
|
|
return `chevron-${direction}`;
|
|
|
|
}),
|
|
|
|
});
|