chore: 🤖 simplify layouts and pageheader
This commit is contained in:
21 files changed
+37
-266
No files matched your search
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../templates/components/rose/page-header/title';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,58 +0,0 @@
|
||||
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { text, select } from '@storybook/addon-knobs';
|
||||
|
||||
<Meta title="Rose|PageHeader|Title" component="Title" />
|
||||
|
||||
# Title
|
||||
|
||||
A header title component with ability to configure dropdown using `Rose::Header::Dropdown`. To be used with `Rose::Layout::PageHeader`.
|
||||
|
||||
```html
|
||||
<Rose::PageHeader::Title as |title| >
|
||||
<title.dropdown
|
||||
@text="Page Header Title"
|
||||
@icon="user-square-fill" as |dropdown|
|
||||
>
|
||||
<dropdown.link @route="index">Menu item</dropdown.link>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
</title.dropdown>
|
||||
</Rose::PageHeader::Title>
|
||||
```
|
||||
|
||||
<Preview>
|
||||
<Story name="Title">{{
|
||||
template: hbs`
|
||||
<Rose::PageHeader::Title as |title| >
|
||||
<title.dropdown
|
||||
@text={{pageTitle}}
|
||||
@icon={{dropdownIcon}} as |dropdown|
|
||||
>
|
||||
<dropdown.link @route="index">Menu item</dropdown.link>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
</title.dropdown>
|
||||
</Rose::PageHeader::Title>
|
||||
`,
|
||||
context: {
|
||||
pageTitle: text('pageTitle', 'Page Section Title'),
|
||||
dropdownIcon: select(
|
||||
'dropdownIcon',
|
||||
{
|
||||
'user-square-fill': 'user-square-fill',
|
||||
'check-circle-outline': 'check-circle-outline',
|
||||
'copy-action': 'copy-action',
|
||||
'unfold-more': 'unfold-more',
|
||||
'unfold-less': 'unfold-less',
|
||||
},
|
||||
'user-square-fill'
|
||||
),
|
||||
},
|
||||
}}</Story>
|
||||
</Preview>
|
||||
|
||||
Title can be configured to be a level 1 heading with optional icon.
|
||||
|
||||
```html
|
||||
<Rose::PageHeader::Title @text="Page Header Title" @icon="alert-circle-fill" />
|
||||
```
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../templates/components/rose/page-header/utilities';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,27 +0,0 @@
|
||||
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
|
||||
<Meta title="Rose|PageHeader" component="Utilities" />
|
||||
|
||||
# Utilities
|
||||
|
||||
An component comprised of `Rose::Button` as actions. To be used with `Rose::Layout::PageHeader`.
|
||||
|
||||
```html
|
||||
<Rose::PageHeader::Utilities as |utilities|>
|
||||
<utilities.action @style="secondary">Secondary</utilities.action>
|
||||
<utilities.action @style="primary">Primary</utilities.action>
|
||||
</Rose::PageHeader::Utilities>
|
||||
```
|
||||
|
||||
<Preview>
|
||||
<Story name="Utilities">{{
|
||||
template: hbs`
|
||||
<Rose::PageHeader::Utilities as |utilities|>
|
||||
<utilities.action @style="secondary">Secondary</utilities.action>
|
||||
<utilities.action @style="primary">Primary</utilities.action>
|
||||
</Rose::PageHeader::Utilities>
|
||||
`,
|
||||
}}</Story>
|
||||
</Preview>
|
||||
+25
-8
@@ -1,11 +1,5 @@
|
||||
@use '../../../variables/sizing';
|
||||
@use '../../../variables/media';
|
||||
|
||||
@import 'breadcrumbs';
|
||||
@import 'header';
|
||||
@import 'actions';
|
||||
@import 'navigation';
|
||||
@import 'body';
|
||||
@use '../../variables/sizing';
|
||||
@use '../../variables/media';
|
||||
|
||||
.rose-layout-page {
|
||||
display: grid;
|
||||
@@ -16,6 +10,29 @@
|
||||
'body body body';
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-rows: auto 1fr;
|
||||
|
||||
.rose-layout-page-breadcrumbs {
|
||||
grid-area: breadcrumbs;
|
||||
}
|
||||
|
||||
.rose-layout-page-header {
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
.rose-layout-page-actions {
|
||||
grid-area: actions;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.rose-layout-page-navigation {
|
||||
grid-area: navigation;
|
||||
}
|
||||
|
||||
.rose-layout-page-body {
|
||||
grid-area: body;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: media.width(small)) {
|
||||
@@ -1,3 +0,0 @@
|
||||
.rose-layout-page-actions {
|
||||
grid-area: actions;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
.rose-layout-page-body {
|
||||
grid-area: body;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
.rose-layout-page-breadcrumbs {
|
||||
grid-area: breadcrumbs;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
.rose-layout-page-header {
|
||||
grid-area: header;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
.rose-layout-page-navigation {
|
||||
grid-area: navigation;
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
import EmberObject from '@ember/object';
|
||||
import ComponentAutoIdMixin from 'rose/mixins/component-auto-id';
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
module('Unit | Mixin | component-auto-id', function () {
|
||||
test('it generates an ID and assigns it to the object', function (assert) {
|
||||
let ComponentAutoIdObject = EmberObject.extend(ComponentAutoIdMixin);
|
||||
let subject = ComponentAutoIdObject.create();
|
||||
assert.ok(subject.id);
|
||||
});
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
<div ...attributes class="rose-page-header-title">
|
||||
{{#if (has-block)}}
|
||||
{{yield (hash
|
||||
dropdown=(component 'rose/header/dropdown' style='dark')
|
||||
)}}
|
||||
{{else}}
|
||||
<section class="rose-page-header-title-section">
|
||||
{{#if @icon}}
|
||||
<span class="rose-page-header-title-icon">{{inline-svg @icon}}</span>
|
||||
{{/if}}
|
||||
|
||||
{{#if @text}}
|
||||
<h1 class="rose-page-header-title-text">{{@text}}</h1>
|
||||
{{/if}}
|
||||
</section>
|
||||
{{/if}}
|
||||
</div>
|
||||
@@ -1,5 +0,0 @@
|
||||
<div ...attributes class="rose-page-header-utilities">
|
||||
{{yield (hash
|
||||
action=(component 'rose/button')
|
||||
)}}
|
||||
</div>
|
||||
@@ -1 +0,0 @@
|
||||
export { default } from 'rose/components/rose/page-header/title';
|
||||
@@ -1 +0,0 @@
|
||||
export { default } from 'rose/components/rose/page-header/utilities';
|
||||
@@ -1,55 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render, click, find, findAll } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
module('Integration | Component | rose/page-header/title', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`<Rose::PageHeader::Title />`);
|
||||
assert.ok(find('.rose-page-header-title'));
|
||||
});
|
||||
|
||||
test('it renders with title', async function (assert) {
|
||||
await render(hbs`<Rose::PageHeader::Title @text="header title" />`);
|
||||
assert.equal(
|
||||
find('.rose-page-header-title-text').textContent.trim(),
|
||||
'header title'
|
||||
);
|
||||
});
|
||||
|
||||
test('it renders with title as dropdown', async function (assert) {
|
||||
await render(hbs`<Rose::PageHeader::Title as |title|>
|
||||
<title.dropdown @text="header title" as |dropdown|>
|
||||
<dropdown.link @route="index">Menu item</dropdown.link>
|
||||
<dropdown.link @route="index">Menu item</dropdown.link>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
</title.dropdown>
|
||||
</Rose::PageHeader::Title>`);
|
||||
assert.equal(
|
||||
find('.rose-header-dropdown-trigger').textContent.trim(),
|
||||
'header title'
|
||||
);
|
||||
assert.equal(findAll('a').length, 2);
|
||||
assert.equal(findAll('button').length, 3);
|
||||
});
|
||||
|
||||
test('it opens title dropdown on click', async function (assert) {
|
||||
await render(hbs`<Rose::PageHeader::Title id="title" as |title|>
|
||||
<title.dropdown id="dropdown" as |dropdown|>
|
||||
<dropdown.link @route="index">Menu item</dropdown.link>
|
||||
<dropdown.link @route="index">Menu item</dropdown.link>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
<dropdown.button>Button menu item</dropdown.button>
|
||||
</title.dropdown>
|
||||
</Rose::PageHeader::Title>`);
|
||||
await click('summary');
|
||||
assert.ok(find('#dropdown').open);
|
||||
await click('#title');
|
||||
assert.notOk(find('#dropdown').open);
|
||||
});
|
||||
});
|
||||
@@ -1,38 +0,0 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render, find, findAll } from '@ember/test-helpers';
|
||||
import hbs from 'htmlbars-inline-precompile';
|
||||
|
||||
module('Integration | Component | rose/page-header/utilities', function (
|
||||
hooks
|
||||
) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function (assert) {
|
||||
await render(hbs`<Rose::PageHeader::Utilities />`);
|
||||
assert.ok(find('.rose-page-header-utilities'));
|
||||
});
|
||||
|
||||
test('it renders with attributes', async function (assert) {
|
||||
await render(hbs`<Rose::PageHeader::Utilities id="utilities"/>`);
|
||||
assert.ok(find('#utilities'));
|
||||
});
|
||||
|
||||
test('it renders with content', async function (assert) {
|
||||
await render(
|
||||
hbs`<Rose::PageHeader::Utilities>Page header utilities</Rose::PageHeader::Utilities>`
|
||||
);
|
||||
assert.equal(
|
||||
find('.rose-page-header-utilities').textContent.trim(),
|
||||
'Page header utilities'
|
||||
);
|
||||
});
|
||||
|
||||
test('it renders utility action buttons', async function (assert) {
|
||||
await render(hbs`<Rose::PageHeader::Utilities as |utility|>
|
||||
<utility.action />
|
||||
<utility.action />
|
||||
</Rose::PageHeader::Utilities>`);
|
||||
assert.equal(findAll('button').length, 2);
|
||||
});
|
||||
});
|
||||
@@ -34,10 +34,6 @@
|
||||
padding: 10px 10px 10px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.rose-layout-page-actions {
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
.project-overview,
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
<Rose::Layout::Page class="projects-overview" as |page|>
|
||||
<page.header>
|
||||
<Rose::PageHeader::Title @text={{t "resources.projects"}} />
|
||||
<h1>{{t "resources.projects"}}</h1>
|
||||
</page.header>
|
||||
|
||||
<page.actions>
|
||||
<Rose::PageHeader::Utilities as |utility|>
|
||||
<utility.action
|
||||
@style="primary"
|
||||
@iconLeft="plus-plain"
|
||||
{{on "click" (route-action "new")}}
|
||||
>
|
||||
{{t 'titles.new'}}
|
||||
</utility.action>
|
||||
</Rose::PageHeader::Utilities>
|
||||
<Rose::Button
|
||||
@style="primary"
|
||||
@iconLeft="plus-plain"
|
||||
{{on "click" (route-action "new")}}
|
||||
>
|
||||
{{t 'titles.new'}}
|
||||
</Rose::Button>
|
||||
</page.actions>
|
||||
|
||||
<page.body>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
<Rose::PageHeader::Title @text={{t "titles.new"}} />
|
||||
<h1>{{t "titles.new"}}</h1>
|
||||
</page.header>
|
||||
|
||||
<page.body>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{{title @model.name}}
|
||||
|
||||
<Rose::Layout::Page class="project-overview" as |page|>
|
||||
<page.breadcrumbs>
|
||||
<div class="breadcrumbs">
|
||||
@@ -8,7 +10,7 @@
|
||||
</page.breadcrumbs>
|
||||
|
||||
<page.header>
|
||||
<Rose::PageHeader::Title @text={{t "resources.project.settings"}} />
|
||||
<h1>{{t "resources.project.settings"}}</h1>
|
||||
</page.header>
|
||||
|
||||
<page.navigation>
|
||||
|
||||
Reference in new issue
Block a user