Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown component, list items #68

Merged
merged 72 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8cf0850
dropdown toggles, initial commit
MelSumner Mar 15, 2022
00177d8
added a few more notes
MelSumner Mar 15, 2022
6906efc
dropdown list items, initial commit
MelSumner Mar 15, 2022
070e0aa
updated toggle component to pass action as a named arg
MelSumner Mar 16, 2022
ab96583
Merge remote-tracking branch 'origin/melsumner/dropdown-toggle' into …
MelSumner Mar 16, 2022
b8e9151
added separator
MelSumner Mar 18, 2022
7839fe4
updated pseudo styles
MelSumner Mar 18, 2022
b762356
refined separator styles
MelSumner Mar 18, 2022
2ca2562
refactored link as grid for icon positioning
MelSumner Mar 18, 2022
a918e0f
added colors for critical focus
MelSumner Mar 18, 2022
195ef9c
commented out dropdown nav for now
MelSumner Mar 21, 2022
96c5dcb
streamlined size conditional in template for toggle
MelSumner Mar 21, 2022
b9aff42
Merge remote-tracking branch 'origin/melsumner/dropdown-component' in…
MelSumner Mar 21, 2022
b103dd0
refactored toggle to be consistent with other button-like components
MelSumner Mar 21, 2022
8c927a8
Merge remote-tracking branch 'origin/melsumner/dropdown-toggle' into …
MelSumner Mar 21, 2022
2807de7
linting and formatting doc seem to be conflicting
MelSumner Mar 21, 2022
dfd6e20
updates to toggle
MelSumner Mar 22, 2022
d2b27db
Merge remote-tracking branch 'origin/melsumner/dropdown-toggle' into …
MelSumner Mar 22, 2022
8ca9936
removed comment in β€œbreadcrumb” main component
didoo Mar 22, 2022
57dc207
updated β€œBreadcrumb” documentation
didoo Mar 22, 2022
4cbad74
Merge pull request #111 from hashicorp/breadcrumb-remove-commment-and…
didoo Mar 23, 2022
f7fb86a
added missing helpers for β€œcolor” and β€œtypography” in β€œcomponents” pa…
didoo Mar 23, 2022
2be0808
changeset
didoo Mar 23, 2022
8148213
adds accessibility statement to app footer (#109)
MelSumner Mar 23, 2022
c46dab8
Merge pull request #112 from hashicorp/add-missing-css-helpers
didoo Mar 23, 2022
b516e9c
Version Packages
github-actions[bot] Mar 23, 2022
178a313
Merge pull request #113 from hashicorp/changeset-release/main
didoo Mar 23, 2022
0986f60
updated the showcase for the β€œDropdown/Toggle” to show all the possib…
didoo Mar 23, 2022
2f4d71b
updated the β€œDropdown/Toggle” to use the β€œHds::Button” component
didoo Mar 23, 2022
5f3af41
updated classname
didoo Mar 23, 2022
4d78e13
started refactoring JS and HBS of the β€œDropdown/Toggle”
didoo Mar 23, 2022
bd86493
finalized styling for the β€œDropdown/Toggle”
didoo Mar 23, 2022
5d7c724
added z-index isolation to the β€œButton” component
didoo Mar 23, 2022
e78f6df
changeset
didoo Mar 23, 2022
f9e7041
updated comment in CSS for β€œDropdown”
didoo Mar 23, 2022
1888c01
fixed index page
didoo Mar 23, 2022
446cf73
commented import to avoid linting error
didoo Mar 23, 2022
f4f86de
Merge branch 'melsumner/dropdown-toggle' into melsumner/dropdown-items
didoo Mar 23, 2022
4df5cde
added showcase for β€œDropdown/List” to show all the possible variants …
didoo Mar 24, 2022
dc1b57e
started refactoring JS and HBS of the β€œDropdown/ListItem”
didoo Mar 24, 2022
0982e19
used β€œrepeat” in all the β€œgrid-template-colums” declarations
didoo Mar 24, 2022
0c90605
Merge branch 'melsumner/dropdown-toggle' into melsumner/dropdown-items
didoo Mar 24, 2022
30cfee4
refactored styling for links
didoo Mar 24, 2022
3b6193e
split the β€œDropdown::Toggle” in specialized sub-components
didoo Mar 24, 2022
8416756
Merge pull request #117 from hashicorp/fix-focus-visibility-in-dummy-…
didoo Mar 24, 2022
f6b5272
small fixes
didoo Mar 24, 2022
6054e2d
Merge remote-tracking branch 'origin/melsumner/dropdown-toggle' into …
didoo Mar 24, 2022
17f5ac2
Merge branch 'main' into melsumner/dropdown-toggle
didoo Mar 24, 2022
397d25d
Merge branch 'main' into melsumner/dropdown-items
didoo Mar 24, 2022
53f1b59
applied filter to avatar image when user toggle is disabled
didoo Mar 24, 2022
5f85126
added missing handling of @isDisabled param for toggle
didoo Mar 24, 2022
7f2c6d9
added handling of β€œisOpen” in toggle
didoo Mar 24, 2022
3e13dd6
Merge remote-tracking branch 'origin/melsumner/dropdown-toggle' into …
didoo Mar 24, 2022
53f30ea
added missing z-index to the dropdown menu
didoo Mar 24, 2022
105a62d
handling of states for showcase
didoo Mar 24, 2022
f6a4754
removed disabled state from β€œitem/link”
didoo Mar 24, 2022
c431818
finalized focus state
didoo Mar 24, 2022
fa2d67d
fine tuned list items according to latest design specs
didoo Mar 24, 2022
cf72582
cleanup
didoo Mar 25, 2022
079f12e
Merge remote-tracking branch 'origin/melsumner/dropdown-component' in…
MelSumner Mar 28, 2022
945a23c
resolved leftovers from merge conflict
MelSumner Mar 28, 2022
6596c73
Merge branch 'melsumner/dropdown-items' of https://github.com/hashico…
MelSumner Mar 28, 2022
f447309
Removed unused files, re-named items per design
MelSumner Mar 28, 2022
c0850ca
where did our auto-linter fixer go?
MelSumner Mar 28, 2022
5bedfe1
resolved issue where correct class wasn't being applied
MelSumner Mar 28, 2022
809ecd1
refactored "is-state" for dummy app
MelSumner Mar 28, 2022
f746174
yet another linter fix
MelSumner Mar 28, 2022
f2c2c3c
added comments for myself, will remove b4 ship
MelSumner Mar 29, 2022
eaf8d43
fixed β€œDropdown” list items
didoo Mar 29, 2022
9d0266b
linting
didoo Mar 29, 2022
59ed231
fixed β€œDropdown” toggles
didoo Mar 29, 2022
9ccc571
small cleanup
didoo Mar 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions packages/components/addon/components/hds/dropdown/list-item.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{#if (eq this.item "heading")}}
<li class={{this.classNames}}>
{{@text}}
</li>

{{else if (eq this.item "help-text")}}
<li class={{this.classNames}}>
{{@text}}
</li>

{{else if (eq this.item "separator")}}
<li class={{this.classNames}} role="separator"></li>

{{else if (eq this.item "copy-item")}}
{{! TODO!! add the copy-item element here }}
<li class={{this.classNames}}>
copy item will go here
</li>

{{else if (eq this.item "link")}}
<li class={{this.classNames}}>
{{#if @route}}
{{! // TODO consider approach }}
<LinkTo @route={{@route}} class="is-{{@state}}">
{{#if @icon}}
<div class="hds-dropdown-list-item__link-icon">
<FlightIcon @name={{@icon}} />
</div>
{{/if}}
<div class="hds-dropdown-list-item__link-text">
{{@text}}
</div>
</LinkTo>
{{else}}
<a target="_blank" rel="noopener noreferrer" href={{@href}} class="is-{{@state}}">
{{#if @icon}}
<div class="hds-dropdown-list-item__link-icon">
<FlightIcon @name={{@icon}} />
</div>
{{/if}}
<div class="hds-dropdown-list-item__link_text">
{{@text}}
</div>
</a>
{{/if}}
</li>

{{/if}}
88 changes: 88 additions & 0 deletions packages/components/addon/components/hds/dropdown/list-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import Component from '@glimmer/component';
import { assert } from '@ember/debug';

export const DEFAULT_COLOR = 'action';
export const DEFAULT_ITEM = 'link';
export const COLORS = ['action', 'critical'];
export const ITEMS = ['heading', 'help-text', 'separator', 'copy-item', 'link'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocker] I am not sure we're going to implement the copy-item in the first release (see comments in #84) so if you want to remove any reference to it in this PR or in the feature branch, is totally OK for me


export default class HdsDropdownListItemComponent extends Component {
/**
* @param text
* @type {string}
* @description The text of the item. If no text value is defined an error will be thrown.
*/
get text() {
let { text } = this.args;

assert(
'@text for "Hds::Dropdown::ListItem" must have a valid value',
text !== undefined
);

return text;
}

/**
* @param color
* @type {string}
* @default primary
* @description Determines the color of the item
*/
get color() {
let { color = DEFAULT_COLOR } = this.args;

assert(
`@color for "Hds::Dropdown::ListItem" must be one of the following: ${COLORS.join(
', '
)}; received: ${color}`,
COLORS.includes(color)
);

return color;
}

/**
* TODO if color is critical, it MUST have an icon
*/

/**
* @param item
* @type {string}
* @default link
* @description Determines the type of item to show
*/
get item() {
let { item = DEFAULT_ITEM } = this.args;

assert(
`@item for "Hds::Dropdown::ListItem" must be one of the following: ${ITEMS.join(
', '
)}; received: ${item}`,
ITEMS.includes(item)
);

return item;
}

/**
* Get the class names to apply to the component.
* @method classNames
* @return {string} The "class" attribute to apply to the component.
*/
get classNames() {
let classes = ['hds-dropdown-list-item'];

// add a class based on the @item argument
if (this.item) {
classes.push(`hds-dropdown-list-item--${this.item}`);
}

// add a class based on the @color argument
if (this.item === 'link' && this.color) {
classes.push(`hds-dropdown-list-item--color-${this.color}`);
}

return classes.join(' ');
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{{!
// β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ
// β–ˆβ–ˆ β–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ
// β–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ
// β–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
// >>>>>>>>>>> WARNING <<<<<<<<<<
//
// Notice: in this component we're using directly the `Hds::Button` component
// Notice: in this component we're directly using the `Hds::Button` component
// (and adding a specialized class for the "toggle-button" variant, see below)
// If you need to change the styling of the `Button` component, remember that this will impact also
// this component too.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assert } from '@ember/debug';
export const DEFAULT_SIZE = 'medium';
export const SIZES = ['medium', 'small'];

export default class HdsDropdownToggleMoreComponent extends Component {
export default class HdsDropdownToggleOverflowComponent extends Component {
/**
* @param text
* @type {string}
Expand All @@ -14,7 +14,7 @@ export default class HdsDropdownToggleMoreComponent extends Component {
let { text } = this.args;

assert(
'@text for "Hds::Dropdown::ToggleMore" must have a valid value',
'@text for "Hds::Dropdown::ToggleOverflow" must have a valid value',
text !== undefined
);

Expand All @@ -31,7 +31,7 @@ export default class HdsDropdownToggleMoreComponent extends Component {
let { size = DEFAULT_SIZE } = this.args;

assert(
`@size for "Hds::Dropdown::ToggleMore" must be one of the following: ${SIZES.join(
`@size for "Hds::Dropdown::ToggleOverflow" must be one of the following: ${SIZES.join(
', '
)}; received: ${size}`,
SIZES.includes(size)
Expand Down Expand Up @@ -66,10 +66,10 @@ export default class HdsDropdownToggleMoreComponent extends Component {
* @return {string} The "class" attribute to apply to the component.
*/
get classNames() {
let classes = ['hds-dropdown-toggle', 'hds-dropdown-toggle--more'];
let classes = ['hds-dropdown-toggle-overflow'];

// add a class based on the @size argument
classes.push(`hds-dropdown-toggle--size-${this.size}`);
classes.push(`hds-dropdown-toggle-overflow--size-${this.size}`);

return classes.join(' ');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<button
class={{this.classNames}}
...attributes
aria-label={{@text}}
type="button"
disabled={{if this.isDisabled "disabled" null}}
...attributes
didoo marked this conversation as resolved.
Show resolved Hide resolved
>
<div class="hds-dropdown-toggle__user">
<div class="hds-dropdown-toggle-user__avatar">
{{#if @avatarUrl}}
<img src={{@avatarUrl}} alt="" role="presentation" height="32" width="32" />
{{else}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class HdsDropdownToggleUserComponent extends Component {
* @return {string} The "class" attribute to apply to the component.
*/
get classNames() {
let classes = ['hds-dropdown-toggle', 'hds-dropdown-toggle--user'];
let classes = ['hds-dropdown-toggle-user'];

return classes.join(' ');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from '@hashicorp/design-system-components/components/hds/disclosure/toggle';
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/list-item';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/toggle-more';
export { default } from '@hashicorp/design-system-components/components/hds/dropdown/toggle-overflow';
1 change: 0 additions & 1 deletion packages/components/app/components/hds/dropdown/toggle.js

This file was deleted.

Loading