Merge branch 'ICU-179-tab-component' of https://github.com/hashicorp/watchtower-ui into ICU-179-tab-component
This commit is contained in:
11 files changed
+196
-1
No files matched your search
@@ -0,0 +1,7 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../templates/components/rose/nav/tab';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { text, boolean, select } from '@storybook/addon-knobs';
|
||||
|
||||
<Meta title="Rose|Nav|Tab" component="Tab" />
|
||||
|
||||
# Tab
|
||||
|
||||
A tab item component with ability to configure icon, title, and badge sections.
|
||||
|
||||
```html
|
||||
<Rose::Nav::Tab @title="Tab item" @badge="3" @icon="info-circle-outline" @disabled={{false}} />
|
||||
```
|
||||
|
||||
<Preview>
|
||||
<Story name="Basic">{{
|
||||
template: hbs`
|
||||
<Rose::Nav::Tab
|
||||
@title={{title}}
|
||||
@badge={{badge}}
|
||||
@icon={{icon}}
|
||||
@disabled={{disabled}}
|
||||
/>`,
|
||||
context: {
|
||||
title: text('title', 'Tab item'),
|
||||
badge: text('badge', '3'),
|
||||
icon: select(
|
||||
'icon',
|
||||
{
|
||||
'info-circle-outline': 'info-circle-outline',
|
||||
'user-square-fill': 'user-square-fill',
|
||||
'check-circle-outline': 'check-circle-outline',
|
||||
'copy-action': 'copy-action',
|
||||
'unfold-more': 'unfold-more',
|
||||
'unfold-less': 'unfold-less',
|
||||
},
|
||||
'info-circle-outline'
|
||||
),
|
||||
disabled: boolean('disabled', false)
|
||||
},
|
||||
}}</Story>
|
||||
</Preview>
|
||||
@@ -1 +1,2 @@
|
||||
@import "sidebar";
|
||||
@import 'tab';
|
||||
@@ -0,0 +1,53 @@
|
||||
@use '../../variables/sizing';
|
||||
@use '../../utilities/type';
|
||||
|
||||
.rose-nav-tab {
|
||||
@include type.type(s);
|
||||
display: inline-block;
|
||||
background-color: var(--subtle);
|
||||
|
||||
.rose-nav-tab-link {
|
||||
text-decoration: none;
|
||||
color: var(--ui-gray);
|
||||
display: inline-block;
|
||||
padding: sizing.rems(s) sizing.rems(m);
|
||||
border-bottom: sizing.rems(xxxs) solid var(--subtle);
|
||||
|
||||
&.rose-nav-tab-link-disabled {
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
color: var(--ui-gray-subtler-2);
|
||||
}
|
||||
|
||||
&:active, &.active {
|
||||
color: var(--action);
|
||||
border-color: var(--action);
|
||||
background-color: var(--subtle);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: var(--ui-gray);
|
||||
border-color: var(--ui-gray-subtler-2);
|
||||
background-color: var(--ui-gray-subtler-4);
|
||||
}
|
||||
|
||||
&:hover:active {
|
||||
color: var(--action);
|
||||
border-color: var(--action);
|
||||
background-color: var(--ui-gray-subtler-4);
|
||||
}
|
||||
}
|
||||
|
||||
.rose-nav-tab-icon {
|
||||
svg {
|
||||
width: sizing.rems(m);
|
||||
height: sizing.rems(m);
|
||||
vertical-align: sub;
|
||||
}
|
||||
}
|
||||
|
||||
.rose-nav-tab-badge {
|
||||
@include type.type(xs);
|
||||
margin-left: sizing.rems(xxs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<div ...attributes class="rose-nav-tab">
|
||||
<LinkTo
|
||||
title={{@title}}
|
||||
@route={{if @route @route "index"}}
|
||||
@model={{@model}}
|
||||
class={{concat "rose-nav-tab-link" (if @disabled " rose-nav-tab-link-disabled")}}
|
||||
>
|
||||
{{#if @icon}}
|
||||
<span class="rose-nav-tab-icon">{{inline-svg @icon}}</span>
|
||||
{{/if}}
|
||||
|
||||
{{#if @title}}
|
||||
<span class="rose-nav-tab-title">{{@title}}</span>
|
||||
{{/if}}
|
||||
|
||||
{{#if @badge}}
|
||||
<span class="rose-nav-tab-badge">{{@badge}}</span>
|
||||
{{/if}}
|
||||
</LinkTo>
|
||||
|
||||
{{yield}}
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from 'rose/components/rose/nav/tab';
|
||||
@@ -198,5 +198,7 @@
|
||||
<Rose::Card::Link @title="I'm a card" />
|
||||
<Rose::Card::Link @title="I'm a card" @description="I'm a description" />
|
||||
<Rose::Card::Link @title="I'm a card" @description="I'm a description" @subtitle="I'm a subtitle"/>
|
||||
|
||||
<Rose::Nav::Tab @title="Text" @badge="3" @icon="info-circle-outline" />
|
||||
</page.main>
|
||||
</Rose::Layout::Page>
|
||||
@@ -0,0 +1,50 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render, find } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
module('Integration | Component | rose/nav/tab', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`<Rose::Nav::Tab />`);
|
||||
assert.ok(find('a'));
|
||||
assert.ok(find('.rose-nav-tab'));
|
||||
assert.ok(find('.rose-nav-tab-link'));
|
||||
assert.notOk(find('.rose-nav-tab-icon'));
|
||||
assert.notOk(find('.rose-nav-tab-badge'));
|
||||
assert.notOk(find('.rose-nav-tab-link-disabled'));
|
||||
});
|
||||
|
||||
test('it renders with title', async function (assert) {
|
||||
await render(hbs`<Rose::Nav::Tab @title="Tab title" />`);
|
||||
assert.equal(find('a').title, 'Tab title');
|
||||
assert.equal(find('.rose-nav-tab-link').textContent.trim(), 'Tab title');
|
||||
});
|
||||
|
||||
test('it renders with icon', async function (assert) {
|
||||
await render(hbs`<Rose::Nav::Tab @icon="info-circle-outline" />`);
|
||||
assert.ok(find('svg'));
|
||||
assert.ok(find('.rose-nav-tab-icon'));
|
||||
});
|
||||
|
||||
test('it renders with badge', async function (assert) {
|
||||
await render(hbs`<Rose::Nav::Tab @badge="3" />`);
|
||||
assert.ok(find('.rose-nav-tab-badge'));
|
||||
assert.equal(find('.rose-nav-tab-badge').textContent.trim(), '3');
|
||||
});
|
||||
|
||||
test('it render with attributes', async function (assert) {
|
||||
await render(hbs`<Rose::Nav::Tab id="tab" />`);
|
||||
assert.ok(find('#tab'));
|
||||
});
|
||||
|
||||
test('it renders disabled', async function (assert) {
|
||||
this.set('disabled', true);
|
||||
await render(hbs`<Rose::Nav::Tab @disabled={{this.disabled}} />`);
|
||||
assert.ok(find('.rose-nav-tab-link-disabled'));
|
||||
|
||||
this.set('disabled', false);
|
||||
assert.notOk(find('.rose-nav-tab-link-disabled'));
|
||||
});
|
||||
});
|
||||
@@ -64,4 +64,12 @@
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.tabs {
|
||||
border-bottom: 2px solid #bac1cc;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,11 @@
|
||||
<LinkTo @route='orgs.org.projects.project'>{{@model.name}}</LinkTo>
|
||||
</div>
|
||||
|
||||
<h2>{{@model.name}}</h2>
|
||||
<h2>{{t "resources.project.settings"}}</h2>
|
||||
|
||||
<div class="tabs">
|
||||
<Rose::Nav::Tab @title={{t "nav.overview"}} @route='orgs.org.projects.project' @model={{@model}} />
|
||||
</div>
|
||||
|
||||
<Form::Project
|
||||
@model={{@model}}
|
||||
|
||||
@@ -5,6 +5,8 @@ actions:
|
||||
save: Save
|
||||
resources:
|
||||
projects: Projects
|
||||
project:
|
||||
settings: Project Settings
|
||||
titles:
|
||||
new: New
|
||||
states:
|
||||
@@ -16,6 +18,8 @@ form:
|
||||
label:
|
||||
name: Name
|
||||
description: Description
|
||||
nav:
|
||||
overview: Overview
|
||||
dev:
|
||||
default-org: Default Org
|
||||
menu-item: Menu item
|
||||
|
||||
Reference in new issue
Block a user