Skip to content

Commit

Permalink
Merge pull request #392 from fabscale/fn/add-stack-grow
Browse files Browse the repository at this point in the history
Add `@grow` parameter to `<Layout::Stack>`
  • Loading branch information
mydea authored Jul 28, 2022
2 parents 9596e3d + 26dc48b commit d90f7e7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions addon/components/layout/stack/item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'layout-stack-item'
(layout-class-if @float 'bottom' 'layout-stack-item--bottom')
(layout-class-if @float 'center' 'layout-stack-item--center')
(layout-class-if @grow true 'layout-stack-item--grow')
}}
...attributes
>{{yield}}</div>
4 changes: 4 additions & 0 deletions addon/styles/addon.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
margin-bottom: auto;
}

.layout-stack-item--grow {
flex-grow: 1;
}

/* Cluster */
.layout-cluster {
--cluster-gap-size: var(--layout-cluster-gap);
Expand Down
7 changes: 7 additions & 0 deletions tests/dummy/app/controllers/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@ export default class StackController extends Controller {
<Item>Third item</Item>
<Item @float="center">Fourth item</Item>
</Layout::Stack>`;

stackCodeGrow = `<Layout::Stack @fullHeight={{true}} as |Item|>
<Item>First item</Item>
<Item>Second item</Item>
<Item>Third item</Item>
<Item @grow={{true}}>Fourth item</Item>
</Layout::Stack>`;
}
41 changes: 41 additions & 0 deletions tests/dummy/app/templates/stack.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,46 @@
</Layout::Stack>
</SectionItem>

<SectionItem>
<h3>
Grow item
</h3>

<p>
Note that this will require the stack to be a specified height (e.g.
full height) to have an effect.
</p>

<Layout::Stack as |StackItem|>
<StackItem>
<CodeBlock @code={{this.stackCodeGrow}} @language='handlebars' />
</StackItem>
<StackItem>
{{! template-lint-disable no-inline-styles }}
<div style='height: 20rem; background: lightgrey'>
<Layout::Stack
@gap={{this.stackGap}}
@withSeparator={{this.stackWithSeparator}}
@fullHeight={{true}}
as |Item|
>
<Item>
<DemoItem />
</Item>
<Item>
<DemoItem />
</Item>
<Item>
<DemoItem />
</Item>
<Item @grow={{true}}>
<DemoItem />
</Item>
</Layout::Stack>
</div>
</StackItem>
</Layout::Stack>
</SectionItem>

</Layout::Stack>
</Layout::Wrapper>

0 comments on commit d90f7e7

Please sign in to comment.