-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flex container): new flex container component
- Loading branch information
1 parent
4ebbbee
commit 7f8c481
Showing
7 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
name: Flex container | ||
route: /flex-container | ||
menu: Components | ||
--- | ||
|
||
# Flex container | ||
|
||
<limel-props name="limel-flex-container" /> | ||
|
||
## Examples | ||
|
||
<limel-example name="limel-example-flex-container" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
:host(limel-flex-container) { | ||
display: flex; | ||
} | ||
:host(limel-flex-container[hidden]) { | ||
display: none; | ||
} | ||
|
||
:host(limel-flex-container[direction="horizontal"]) { | ||
flex-direction: row; | ||
} | ||
:host(limel-flex-container[direction="horizontal"][reverse]) { | ||
flex-direction: row-reverse; | ||
} | ||
:host(limel-flex-container[direction='vertical']) { | ||
flex-direction: column; | ||
} | ||
:host(limel-flex-container[direction='vertical'][reverse]) { | ||
flex-direction: column-reverse; | ||
} | ||
|
||
:host(limel-flex-container[align='start']) { | ||
align-items: flex-start; | ||
} | ||
:host(limel-flex-container[align='end']) { | ||
align-items: flex-end; | ||
} | ||
:host(limel-flex-container[align='center']) { | ||
align-items: center; | ||
} | ||
:host(limel-flex-container[align='stretch']) { | ||
align-items: stretch; | ||
} | ||
|
||
:host(limel-flex-container[justify='start']) { | ||
justify-content: flex-start; | ||
} | ||
:host(limel-flex-container[justify='end']) { | ||
justify-content: flex-end; | ||
} | ||
:host(limel-flex-container[justify='center']) { | ||
justify-content: center; | ||
} | ||
:host(limel-flex-container[justify='space-between']) { | ||
justify-content: space-between; | ||
} | ||
:host(limel-flex-container[justify='space-around']) { | ||
justify-content: space-around; | ||
} | ||
:host(limel-flex-container[justify='space-evenly']) { | ||
justify-content: space-evenly; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type FlexContainerDirection = 'horizontal' | 'vertical'; | ||
export type FlexContainerAlign = 'start' | 'end' | 'center' | 'stretch'; | ||
export type FlexContainerJustify = | ||
| 'start' | ||
| 'end' | ||
| 'center' | ||
| 'space-between' | ||
| 'space-around' | ||
| 'space-evenly'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Component, Prop } from '@stencil/core'; | ||
import { | ||
FlexContainerAlign, | ||
FlexContainerDirection, | ||
FlexContainerJustify, | ||
} from './flex-container'; | ||
|
||
@Component({ | ||
tag: 'limel-flex-container', | ||
shadow: true, | ||
styleUrl: 'flex-container.scss', | ||
}) | ||
export class FlexContainer { | ||
/** | ||
* Direction of the main axis | ||
*/ | ||
@Prop({ reflectToAttr: true }) | ||
public direction: FlexContainerDirection = 'horizontal'; | ||
|
||
/** | ||
* Specify how items are aligned along the main axis | ||
*/ | ||
@Prop({ reflectToAttr: true }) | ||
public justify: FlexContainerJustify = 'space-between'; | ||
|
||
/** | ||
* Specify how items are aligned along the cross axis | ||
*/ | ||
@Prop({ reflectToAttr: true }) | ||
public align: FlexContainerAlign = 'center'; | ||
|
||
/** | ||
* Reverse the order of the items | ||
*/ | ||
@Prop({ reflectToAttr: true }) | ||
public reverse = false; | ||
|
||
public render() { | ||
return <slot />; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
limel-flex-container { | ||
margin-bottom: 2rem; | ||
|
||
&.container { | ||
height: 60rem; | ||
border: 0.1rem solid var(--lime-dark-grey); | ||
border-radius: 0.3rem; | ||
} | ||
|
||
div { | ||
display: block; | ||
padding: 2.5rem 5rem; | ||
|
||
text-align: center; | ||
color: white; | ||
font-size: 2rem; | ||
line-height: 0; | ||
|
||
&:nth-child(1) { | ||
background-color: var(--lime-red); | ||
padding: 1.25rem 5rem; | ||
} | ||
&:nth-child(2) { | ||
background-color: var(--lime-orange); | ||
padding: 5rem; | ||
} | ||
&:nth-child(3) { | ||
background-color: var(--lime-green); | ||
} | ||
&:nth-child(4) { | ||
background-color: var(--lime-blue); | ||
padding: 2.5rem 10rem; | ||
} | ||
&:nth-child(5) { | ||
background-color: var(--lime-magenta); | ||
padding: 2.5rem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { Component, State } from '@stencil/core'; | ||
import { | ||
FlexContainerAlign, | ||
FlexContainerDirection, | ||
FlexContainerJustify, | ||
} from '../../components/flex-container/flex-container'; | ||
import { Option } from '../../components/select/option'; | ||
|
||
@Component({ | ||
tag: 'limel-example-flex-container', | ||
shadow: true, | ||
styleUrl: 'flex-container.scss', | ||
}) | ||
export class FlexContainerExample { | ||
private directionOptions: Array<Option<FlexContainerDirection>> = [ | ||
{ | ||
text: 'Horizontal', | ||
value: 'horizontal', | ||
}, | ||
{ | ||
text: 'Vertical', | ||
value: 'vertical', | ||
}, | ||
]; | ||
|
||
private alignOptions: Array<Option<FlexContainerAlign>> = [ | ||
{ | ||
value: 'start', | ||
text: 'Start', | ||
}, | ||
{ | ||
value: 'center', | ||
text: 'Center', | ||
}, | ||
{ | ||
value: 'end', | ||
text: 'End', | ||
}, | ||
{ | ||
value: 'stretch', | ||
text: 'Stretch', | ||
}, | ||
]; | ||
|
||
private justifyOptions: Array<Option<FlexContainerJustify>> = [ | ||
{ | ||
value: 'start', | ||
text: 'Start', | ||
}, | ||
{ | ||
value: 'center', | ||
text: 'Center', | ||
}, | ||
{ | ||
value: 'end', | ||
text: 'End', | ||
}, | ||
{ | ||
value: 'space-around', | ||
text: 'Space around', | ||
}, | ||
{ | ||
value: 'space-between', | ||
text: 'Space between', | ||
}, | ||
{ | ||
value: 'space-evenly', | ||
text: 'Space evenly', | ||
}, | ||
]; | ||
|
||
@State() | ||
private direction: Option<FlexContainerDirection>; | ||
|
||
@State() | ||
private align: Option<FlexContainerAlign>; | ||
|
||
@State() | ||
private justify: Option<FlexContainerJustify>; | ||
|
||
@State() | ||
private reverse = false; | ||
|
||
public componentWillLoad() { | ||
this.direction = this.directionOptions[0]; | ||
this.align = this.alignOptions[0]; | ||
this.justify = this.justifyOptions[0]; | ||
} | ||
|
||
public render() { | ||
return [ | ||
<limel-flex-container justify="space-between"> | ||
<limel-select | ||
label="Direction" | ||
options={this.directionOptions} | ||
value={this.direction} | ||
onChange={( | ||
event: CustomEvent<Option<FlexContainerDirection>> | ||
) => { | ||
this.direction = event.detail; | ||
}} | ||
/> | ||
<limel-select | ||
label="Align" | ||
options={this.alignOptions} | ||
value={this.align} | ||
onChange={( | ||
event: CustomEvent<Option<FlexContainerAlign>> | ||
) => { | ||
this.align = event.detail; | ||
}} | ||
/> | ||
<limel-select | ||
label="Justify" | ||
options={this.justifyOptions} | ||
value={this.justify} | ||
onChange={( | ||
event: CustomEvent<Option<FlexContainerJustify>> | ||
) => { | ||
this.justify = event.detail; | ||
}} | ||
/> | ||
<limel-checkbox | ||
label="Reverse" | ||
checked={this.reverse} | ||
onChange={(event: CustomEvent<boolean>) => { | ||
this.reverse = event.detail; | ||
}} | ||
/> | ||
</limel-flex-container>, | ||
<limel-flex-container | ||
class="container" | ||
direction={this.direction.value} | ||
align={this.align.value} | ||
justify={this.justify.value} | ||
reverse={this.reverse} | ||
> | ||
<div>1</div> | ||
<div>2</div> | ||
<div>3</div> | ||
<div>4</div> | ||
<div>5</div> | ||
</limel-flex-container>, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters