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

UI icon size #6736

Merged
merged 3 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ui/app/templates/components/alert-popup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="column is-narrow message-icon">
<Icon
aria-hidden="true"
class="hs-icon-l"
@size="l"
@glyph="{{type.glyph}}"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/console/command-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<input onkeyup={{action 'handleKeyUp'}} value={{value}} autocomplete="off" spellcheck="false" />
{{#tool-tip horizontalPosition="auto-right" verticalPosition=(if isFullscreen "above" "below") as |d|}}
{{#d.trigger tagName="button" type="button" class=(concat "button is-compact" (if isFullscreen " active")) click=(action "fullscreen") data-test-tool-tip-trigger=true}}
<Icon class="hs-icon-l" @glyph={{if isFullscreen "expand-less" "expand-more"}} aria-label={{if isFullscreen "Minimize" "Maximize"}} />
<Icon @size="l" @glyph={{if isFullscreen "expand-less" "expand-more"}} aria-label={{if isFullscreen "Minimize" "Maximize"}} />
{{/d.trigger}}
{{#d.content class="tool-tip"}}
<div class="box">
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/kv-object-editor.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
aria-label="Delete row"
data-test-kv-delete-row
>
<Icon @glyph="trash" class="hs-icon-l" />
<Icon @glyph="trash" @size="l" />
</button>
{{/if}}
</div>
Expand Down
14 changes: 12 additions & 2 deletions ui/app/templates/components/license-info.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,20 @@
{{#each featuresInfo as |info|}}
{{#info-table-row label=info.name value=(if info.active "Active" "Not Active") data-test-feature-row="data-test-feature-row"}}
{{#if info.active}}
<Icon @glyph="check-circle-outline" class="hs-icon-l icon-true" aria-hidden="true" /> <span data-test-feature-status>Active {{#if info.count}}&mdash;
<Icon
@glyph="check-circle-outline"
@size="l"
class="icon-true"
aria-hidden="true"
/><span data-test-feature-status>Active {{#if info.count}}&mdash;
{{info.count}} standby nodes allotted{{/if}}</span>
{{else}}
<Icon @glyph="cancel-circle-outline" class="hs-icon-l icon-false" aria-hidden="true" /> <span data-test-feature-status>Not Active</span>
<Icon
@glyph="cancel-circle-outline"
@size="l"
class="icon-false"
aria-hidden="true"
/><span data-test-feature-status>Not Active</span>
{{/if}}
{{/info-table-row}}
{{/each}}
Expand Down
6 changes: 4 additions & 2 deletions ui/app/templates/components/mount-backend-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
{{#with (find-by "type" mountModel.type mountTypes) as |typeInfo|}}
<Icon
@glyph={{or typeInfo.glyph typeInfo.type}}
class="has-text-grey-light hs-icon-l"
@size="l"
class="has-text-grey-light"
/>

{{#if (eq mountType "auth")}}
Expand Down Expand Up @@ -57,7 +58,8 @@
>
<Icon
@glyph={{or type.glyph type.type}}
class="has-text-grey-light hs-icon-xl"
@size="xl"
class="has-text-grey-light"
/>

{{type.displayName}}
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/navigate-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
onfocus={{action "setFilterFocused" true}}
onblur={{action "setFilterFocused" false}}
/>
<Icon @glyph="search" class="search-icon has-text-grey-light hs-icon-l" />
<Icon @glyph="search" @size="l" class="search-icon has-text-grey-light" />
</p>
</div>
3 changes: 2 additions & 1 deletion ui/app/templates/components/secret-edit-display.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
>
<Icon
@glyph="trash"
class="hs-icon-l has-text-grey-light"
@size="l"
class="has-text-grey-light"
/>
</button>
{{/if}}
Expand Down
6 changes: 5 additions & 1 deletion ui/app/templates/components/secret-list-header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
</p.top>
<p.levelLeft>
<h1 class="title is-3">
<Icon @glyph={{or model.engineType "secrets"}} class="hs-icon-xl has-text-grey-light" />
<Icon
@glyph={{or model.engineType "secrets"}}
@size="xl"
class="has-text-grey-light"
/>
{{model.id}}
{{#if (eq model.options.version 2)}}
<span class="tag">
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/status-menu.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#basic-dropdown-hover horizontalPosition="auto-left" verticalPosition="below" renderInPlace=media.isMobile as |d|}}
{{#d.trigger tagName=(if (eq type "replication") "span" "button") class=(if (eq type "replication") "" "button is-transparent")}}
<Icon @glyph={{glyphName}} class="hs-icon-l" @aria-label={{ariaLabel}} />
<Icon @glyph={{glyphName}} @size="l" aria-label={{ariaLabel}} />
<div class="status-menu-label">
{{label}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/string-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
data-test-string-list-button="delete"
{{action "removeInput" index}}
>
<Icon @glyph="trash" class="hs-icon-l" />
<Icon @glyph="trash" @size="l" />
</button>
{{/if}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/wizard-content.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PopupMenu>
{{/unless}}
<h1 class="title is-5">
<Icon @glyph={{glyph}} class="hs-icon-l"/> {{headerText}}
<Icon @glyph={{glyph}} @size="l"/> {{headerText}}
</h1>
{{#if showProgress}}
<ToolTip @verticalPosition="below" as |T|>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/wizard-section.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="wizard-section {{class}}">
<h2 class="title is-6">
{{#if headerIcon}}
<Icon @glyph={{headerIcon}} class="hs-icon-l" aria-hidden="true" />
<Icon @glyph={{headerIcon}} @size="l" aria-hidden="true" />
{{/if}}
{{headerText}}
</h2>
Expand Down
6 changes: 5 additions & 1 deletion ui/app/templates/vault.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
{{outlet}}
<footer class="footer has-text-grey has-text-centered">
<span class="is-inline-block">
<Icon @glyph="hashicorp" aria-hidden="true" class="hs-icon-l has-text-grey-light" />
<Icon
@glyph="hashicorp"
@size="l"
aria-hidden="true"
class="has-text-grey-light" />
&copy; {{date-format (now) "YYYY"}} HashiCorp
</span>
<span>
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/vault/cluster.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
as |Nav|>
<Nav.home>
<HomeLink @class="navbar-item has-text-white has-current-color-fill">
<Icon @glyph="vault-logo" class="hs-icon-l" />
<Icon @glyph="vault-logo" @size="l" />
</HomeLink>
</Nav.home>
<Nav.main>
Expand Down Expand Up @@ -76,7 +76,7 @@
<div class="navbar-item">
<button type="button" class="button is-transparent nav-console-button{{if consoleOpen " popup-open"}}"
{{action (queue (action 'toggleConsole') (action Nav.closeDrawer))}} data-test-console-toggle>
<Icon @glyph="console" class="hs-icon-l" />
<Icon @glyph="console" @size="l" />
<div class="status-menu-label">
Console
</div>
Expand Down
5 changes: 4 additions & 1 deletion ui/app/templates/vault/cluster/access/methods.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
)
method.methodType
"auth"
}} @class="hs-icon-l has-text-grey-light"/>
}}
@size="l"
class="has-text-grey-light"
/>
</T.trigger>
<T.content @class="tool-tip">
<div class="box">
Expand Down
11 changes: 9 additions & 2 deletions ui/app/templates/vault/cluster/secrets/backends.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
<div>
<ToolTip @horizontalPosition="left" as |T|>
<T.trigger>
<Icon @glyph={{or backend.engineType "secrets"}} class="hs-icon-l has-text-grey-light" />
<Icon
@glyph={{or backend.engineType "secrets"}}
@size="l"
class="has-text-grey-light"
/>
</T.trigger>
<T.content @class="tool-tip">
<div class="box">
Expand Down Expand Up @@ -102,7 +106,10 @@
<div data-test-secret-path class="has-text-weight-semibold has-text-grey">
<ToolTip @horizontalPosition="left" as |T|>
<T.trigger>
<Icon @glyph={{or backend.engineType "secrets"}} class="has-text-grey-light"/>
<Icon
@glyph={{or backend.engineType "secrets"}}
class="has-text-grey-light"
/>
</T.trigger>
<T.content @class="tool-tip">
<div class="box">
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/vault/not-found.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<nav class="navbar is-grouped-split">
<div class="navbar-brand">
<HomeLink @class="navbar-item has-text-white has-current-color-fill">
<Icon @glyph="vault-logo" class="hs-icon-l" />
<Icon @glyph="vault-logo" @size="l" />
</HomeLink>
</div>
</nav>
Expand Down
17 changes: 17 additions & 0 deletions ui/lib/core/addon/components/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,30 @@
* <Icon @glyph="cancel-square-outline" />
* ```
* @param glyph=null {String} - The name of the SVG to render inline.
* @param [size='m'] {String} - The size of the Icon, can be one of 's', 'm', 'l', 'xl', 'xxl'. The default is 'm'.
*
*/
import Component from '@ember/component';
import { computed } from '@ember/object';
import { assert } from '@ember/debug';
import layout from '../templates/components/icon';

const SIZES = ['s', 'm', 'l', 'xl', 'xxl'];

export default Component.extend({
tagName: '',
layout,
glyph: null,
size: 'm',
sizeClass: computed('size', function() {
let { size } = this;
assert(
`The size property of ${this.toString()} must be one of the following: ${SIZES.join(', ')}`,
SIZES.includes(size)
);
if (size === 'm') {
return '';
}
return `hs-icon-${size}`;
}),
});
3 changes: 2 additions & 1 deletion ui/lib/core/addon/templates/components/alert-banner.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<div class="columns is-mobile is-variable is-1">
<div class="column is-narrow message-icon">
<Icon
class="hs-icon-l {{alertType.glyphClass}}"
@size="l"
class="{{alertType.glyphClass}}"
aria-hidden=true
@glyph={{alertType.glyph}}
/>
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/core/addon/templates/components/icon.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span class="hs-icon {{class}}" ...attributes>
<span class="hs-icon {{sizeClass}} {{class}}" ...attributes>
{{svg-jar @glyph}}
</span>
6 changes: 4 additions & 2 deletions ui/lib/core/addon/templates/components/info-table-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
{{#if value}}
<Icon
aria-hidden="true"
class="hs-icon-l icon-true"
class="icon-true"
@size="l"
@glyph="check-circle-outline"
/> Yes
{{else}}
<Icon
aria-hidden="true"
class="hs-icon-l icon-false"
class="icon-false"
@size="l"
@glyph="cancel-circle-outline"
/> No
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/core/addon/templates/components/upgrade-link.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="modal-background"></div>
<div class="modal-content">
<h2 class="title upgrade-overlay-title is-2 has-text-white">
<Icon @glyph="edition-enterprise" aria-hidden="true" class="hs-icon-xl" />
<Icon @glyph="edition-enterprise" aria-hidden="true" @size="xl" />
Try Vault Enterprise free for 30 days
</h2>
<h3 class="title is-5 has-text-white">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{{#if (eq initialReplicationMode 'dr')}}
<h3 class="title is-flex-center is-5 is-marginless">
<Icon
class="hs-icon-xl"
@size="xl"
aria-hidden="true"
@glyph="replication"
/>
Expand All @@ -51,7 +51,7 @@
{{else if (eq initialReplicationMode 'performance')}}
<h3 class="title is-flex-center is-5 is-marginless">
<Icon
class="hs-icon-xl"
@size="xl"
aria-hidden="true"
@glyph="perf-replication"
/>
Expand Down Expand Up @@ -80,7 +80,7 @@
<div>
<h3 class="box-label-header title is-6">
<Icon
class="hs-icon-xl"
@size="xl"
aria-hidden="true"
@glyph="replication"
/>
Expand All @@ -106,7 +106,7 @@
<div>
<h3 class="box-label-header title is-6">
<Icon
class="hs-icon-xl"
@size="xl"
aria-hidden="true"
@glyph="perf-replication"
/>
Expand Down Expand Up @@ -286,7 +286,7 @@
<div class="box is-sideless is-fullwidth is-marginless">
<h3 class="title is-flex-center is-5 is-marginless">
<Icon
class="hs-icon-xl"
@size="xl"
aria-hidden="true"
@glyph="replication"
/>
Expand Down Expand Up @@ -315,7 +315,7 @@
<div class="box is-bottomless is-fullwidth is-marginless">
<h3 class="title is-flex-center is-5 is-marginless">
<Icon
class="hs-icon-xl"
@size="xl"
aria-hidden="true"
@glyph="perf-replication"
/>
Expand Down
7 changes: 5 additions & 2 deletions ui/stories/icon.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import hbs from 'htmlbars-inline-precompile';
import { storiesOf } from '@storybook/ember';
import notes from './icon.md';
import icons from '../node_modules/@hashicorp/structure-icons/dist/index.js';
import { withKnobs, select } from '@storybook/addon-knobs';

storiesOf('Icon/', module)
.addParameters({ options: { showPanel: false } })
.addParameters({ options: { showPanel: true} })

Choose a reason for hiding this comment

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

Not sure if you left this in by accident (showPanel: true)? Ah, maybe you want the panel in now as you have a setting you can tweak.? Will leave this comment in just incase, but 99% sure this is good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is so that the knobs panel shows up when you click Icon in the sidebar, otherwise it's hidden. We usually hide it if we're not using the knobs decorator, but since I added it here, I flipped it to true.

Choose a reason for hiding this comment

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

Sweet gotcha 👍

.addDecorator(withKnobs())
.add(
'Icon',
() => ({
Expand All @@ -25,7 +27,7 @@ storiesOf('Icon/', module)
<h5>{{humanize type}}</h5>
</td>
<td>
<Icon @glyph={{type}} />
<Icon @glyph={{type}} @size={{size}} />
</td>
</tr>
{{/each}}
Expand All @@ -34,6 +36,7 @@ storiesOf('Icon/', module)
`,
context: {
types: icons,
size: select('Size', ['s', 'm', 'l', 'xl', 'xxl'], 'm'),
},
}),
{ notes }
Expand Down
9 changes: 9 additions & 0 deletions ui/tests/integration/components/icon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import waitForError from 'vault/tests/helpers/wait-for-error';

module('Integration | Component | icon', function(hooks) {
setupRenderingTest(hooks);
Expand All @@ -18,5 +19,13 @@ module('Integration | Component | icon', function(hooks) {

await render(hbs`<Icon class="al" aria-label="Testing" />`);
assert.dom('.al').hasAttribute('aria-label', 'Testing', 'renders aria-label');

await render(hbs`<Icon @glyph="vault-logo" @size="s"/>`);
assert.dom('.hs-icon').hasClass('hs-icon-s', 'adds the size class');

let promise = waitForError();
render(hbs`<Icon @glyph="vault-logo" @size="no"/>`);
let err = await promise;
assert.ok(err.message.includes('The size property of'), "errors when passed a size that's not allowed");
});
});