refactor: 💡 replace layout regions with anonymous component
This commit is contained in:
47 files changed
+108
-362
No files matched your search
@@ -0,0 +1,10 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../templates/components/rose/anonymous';
|
||||
|
||||
/**
|
||||
* An otherwise empty component that renders a block. Used only by components
|
||||
* that yield simple contextual components, such as layouts yielding regions.
|
||||
*/
|
||||
export default Component.extend({
|
||||
layout
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
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|Anonymous" component="Anonymous" />
|
||||
|
||||
# Anonymous
|
||||
|
||||
The anonymous component is a simple `<div>` with no attributes of its own.
|
||||
It is used by other components that need to yield contextual components.
|
||||
This component should not be instantiated directly.
|
||||
|
||||
For example, layout components may yield an anonymous component to configure
|
||||
various layout regions:
|
||||
|
||||
```htmlbars
|
||||
<div ...attributes class="rose-layout-global">
|
||||
{{yield (hash
|
||||
header=(component "rose/anonymous" tagName="header" class="rose-layout-global-header")
|
||||
sidebar=(component "rose/anonymous" tagName="aside" class="rose-layout-global-sidebar")
|
||||
body=(component "rose/anonymous" tagName="main" class="rose-layout-global-body")
|
||||
)}}
|
||||
</div>
|
||||
```
|
||||
@@ -10,20 +10,20 @@ import { text, boolean, select } from '@storybook/addon-knobs';
|
||||
A top-level layout/positioning component that allows three distinct sections to be configured: header, navigation, and body.
|
||||
|
||||
```htmlbars
|
||||
<Rose::Layout::Global as |global|>
|
||||
<global.header />
|
||||
<global.body />
|
||||
<global.navigation />
|
||||
<Rose::Layout::Global as |layout|>
|
||||
<layout.header />
|
||||
<layout.sidebar />
|
||||
<layout.body />
|
||||
</Rose::Layout::Global>
|
||||
```
|
||||
|
||||
<Preview>
|
||||
<Story name="Global">{{
|
||||
template: hbs`
|
||||
<Rose::Layout::Global as |global|>
|
||||
<global.header style="background: var(--brand-gray-5);">Header</global.header>
|
||||
<global.body style="background: var(--brand-gray-7);">Body</global.body>
|
||||
<global.navigation style="background: var(--brand-gray-6);">Navigation</global.navigation>
|
||||
<Rose::Layout::Global as |layout|>
|
||||
<layout.header style="background: var(--brand-gray-5);">Header</layout.header>
|
||||
<layout.sidebar style="background: var(--brand-gray-6);">Sidebar</layout.sidebar>
|
||||
<layout.body style="background: var(--brand-gray-7);">Body</layout.body>
|
||||
</Rose::Layout::Global>
|
||||
`,
|
||||
}}</Story>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/global/body';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/global/header';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/global/navigation';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/page/actions';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/page/body';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/page/breadcrumbs';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/page/header';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
import Component from '@ember/component';
|
||||
import layout from '../../../../templates/components/rose/layout/page/navigation';
|
||||
|
||||
export default Component.extend({
|
||||
layout,
|
||||
tagName: '',
|
||||
});
|
||||
+16
-6
@@ -1,9 +1,5 @@
|
||||
@use '../../../variables/sizing';
|
||||
@use '../../../variables/media';
|
||||
|
||||
@import 'header';
|
||||
@import 'body';
|
||||
@import 'navigation';
|
||||
@use '../../variables/sizing';
|
||||
@use '../../variables/media';
|
||||
|
||||
.rose-layout-global {
|
||||
display: grid;
|
||||
@@ -14,6 +10,20 @@
|
||||
grid-template-columns: (sizing.rems(m) * 16) auto 1fr;
|
||||
grid-template-rows: auto 1fr;
|
||||
height: 100vh;
|
||||
|
||||
.rose-layout-global-body {
|
||||
grid-area: body;
|
||||
}
|
||||
|
||||
.rose-layout-global-header {
|
||||
grid-area: header;
|
||||
}
|
||||
|
||||
.rose-layout-global-sidebar {
|
||||
grid-area: navigation;
|
||||
border-right: sizing.rems(xxxxs) solid var(--ui-border-subtler-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: media.width(small)) {
|
||||
@@ -1,3 +0,0 @@
|
||||
.rose-layout-global-body {
|
||||
grid-area: body;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
.rose-layout-global-header {
|
||||
grid-area: header;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
@use '../../../variables/sizing';
|
||||
|
||||
.rose-layout-global-navigation {
|
||||
grid-area: navigation;
|
||||
border-right: sizing.rems(xxxxs) solid var(--ui-border-subtler-1);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{{yield}}
|
||||
@@ -1,7 +1,7 @@
|
||||
<div ...attributes class="rose-layout-global">
|
||||
{{yield (hash
|
||||
header=(component 'rose/layout/global/header')
|
||||
body=(component 'rose/layout/global/body')
|
||||
navigation=(component 'rose/layout/global/navigation')
|
||||
header=(component "rose/anonymous" tagName="header" class="rose-layout-global-header")
|
||||
sidebar=(component "rose/anonymous" tagName="aside" class="rose-layout-global-sidebar")
|
||||
body=(component "rose/anonymous" tagName="main" class="rose-layout-global-body")
|
||||
)}}
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<main ...attributes class="rose-layout-global-body">
|
||||
{{yield}}
|
||||
</main>
|
||||
@@ -1,3 +0,0 @@
|
||||
<header ...attributes class="rose-layout-global-header" >
|
||||
{{yield}}
|
||||
</header>
|
||||
@@ -1,3 +0,0 @@
|
||||
<aside ...attributes class="rose-layout-global-navigation">
|
||||
{{yield}}
|
||||
</aside>
|
||||
@@ -1,9 +1,9 @@
|
||||
<div ...attributes class="rose-layout-page">
|
||||
{{yield (hash
|
||||
breadcrumbs=(component 'rose/layout/page/breadcrumbs')
|
||||
header=(component 'rose/layout/page/header')
|
||||
actions=(component 'rose/layout/page/actions')
|
||||
navigation=(component 'rose/layout/page/navigation')
|
||||
body=(component 'rose/layout/page/body')
|
||||
breadcrumbs=(component "rose/anonymous" class="rose-layout-page-breadcrumbs")
|
||||
header=(component "rose/anonymous" class="rose-layout-page-header")
|
||||
actions=(component "rose/anonymous" class="rose-layout-page-actions")
|
||||
navigation=(component "rose/anonymous" class="rose-layout-page-navigation")
|
||||
body=(component "rose/anonymous" class="rose-layout-page-body")
|
||||
)}}
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div ...attributes class="rose-layout-page-actions">
|
||||
{{yield}}
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div ...attributes class="rose-layout-page-body">
|
||||
{{yield}}
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div ...attributes class="rose-layout-page-breadcrumbs">
|
||||
{{yield}}
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div ...attributes class="rose-layout-page-header">
|
||||
{{yield}}
|
||||
</div>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div ...attributes class="rose-layout-page-navigation">
|
||||
{{yield}}
|
||||
</div>
|
||||
Reference in new issue
Block a user