-
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.
- Loading branch information
1 parent
51a0925
commit 8955a69
Showing
6 changed files
with
224 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,14 @@ | ||
--- | ||
name: Banner | ||
route: /banner | ||
menu: Components | ||
--- | ||
|
||
# Banner | ||
|
||
<limel-props name="limel-banner" /> | ||
|
||
## Example | ||
|
||
<limel-example name="limel-example-banner" /> | ||
|
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,47 @@ | ||
@import '@limetech/mdc-elevation/mixins'; | ||
@import '@limetech/mdc-theme/mixins'; | ||
@import '../../style/variables'; | ||
@import '../../style/functions.scss'; | ||
|
||
.lime-banner { | ||
min-height: $lime-banner-height; | ||
@include mdc-theme-prop(background-color, surface); | ||
@include mdc-elevation(1); | ||
display: none; | ||
&.lime-banner--open { | ||
display: block; | ||
.lime-banner__surface { | ||
opacity: 1; | ||
} | ||
} | ||
.lime-banner__surface { | ||
display: flex; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
opacity: 0; | ||
} | ||
|
||
.lime-banner__content { | ||
display: flex; | ||
align-items: center; | ||
align-content: stretch; | ||
padding: pxToRem(16); | ||
flex-wrap: wrap; | ||
} | ||
|
||
.lime-banner__icon { | ||
margin: 0 pxToRem(10); | ||
align-self: flex-start; | ||
} | ||
|
||
.lime-banner__actions { | ||
margin-left: pxToRem(50); | ||
display: flex; | ||
justify-content: flex-end; | ||
} | ||
|
||
limel-icon { | ||
color: white; | ||
background-color: var(--icon-background-color, var(--lime-dark-grey)); | ||
} | ||
} |
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,75 @@ | ||
import { Component, h, Method, Prop, State } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'limel-banner', | ||
shadow: true, | ||
styleUrl: 'banner.scss', | ||
}) | ||
export class Banner { | ||
/** | ||
* The text to show on the banner. | ||
*/ | ||
@Prop({ reflectToAttr: true }) | ||
public message: string; | ||
|
||
/** | ||
* Set icon for the banner | ||
*/ | ||
@Prop({ reflectToAttr: true }) | ||
public icon: string; | ||
|
||
@State() | ||
private isOpen = false; | ||
|
||
// tslint:disable-next-line:valid-jsdoc | ||
/** | ||
* Open the banner | ||
*/ | ||
@Method() | ||
public async open() { | ||
this.isOpen = true; | ||
} | ||
|
||
// tslint:disable-next-line:valid-jsdoc | ||
/** | ||
* Close the banner | ||
*/ | ||
@Method() | ||
public async close() { | ||
this.isOpen = false; | ||
} | ||
|
||
public render() { | ||
return ( | ||
<div | ||
class={`lime-banner ${this.isOpen ? 'lime-banner--open' : ''}`} | ||
> | ||
<div class="lime-banner__surface"> | ||
<div class="lime-banner__content"> | ||
{this.renderIcon()} | ||
<div class="mdc-typography--body2">{this.message}</div> | ||
<div class="lime-banner__actions"> | ||
<slot name="buttons" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
/** | ||
* Render the icon for the button | ||
* | ||
* @returns {HTMLElement} the icon | ||
*/ | ||
private renderIcon() { | ||
if (!this.icon) { | ||
return; | ||
} | ||
return ( | ||
<div class="lime-banner__icon"> | ||
<limel-icon name={this.icon} badge={true} size="large" /> | ||
</div> | ||
); | ||
} | ||
} |
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,17 @@ | ||
@import '../../style/functions.scss'; | ||
|
||
limel-banner { | ||
--icon-background-color: var(--lime-deep-red); | ||
position: fixed; | ||
right: 0; | ||
top: 0; | ||
left: 0; | ||
|
||
@media (max-width: 720px) { | ||
position: absolute; | ||
} | ||
|
||
limel-button:not(last-child) { | ||
margin-right: pxToRem(10); | ||
} | ||
} |
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,67 @@ | ||
import { Component, Element, h, State } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'limel-example-banner', | ||
shadow: true, | ||
styleUrl: 'banner.scss', | ||
}) | ||
export class BannerExample { | ||
@Element() | ||
private host: HTMLElement; | ||
|
||
@State() | ||
private disabled = false; | ||
|
||
private message = 'This is a non-blocking but also non-transient message'; | ||
|
||
private banner: HTMLLimelBannerElement; | ||
|
||
constructor() { | ||
this.openBanner = this.openBanner.bind(this); | ||
this.closeBanner = this.closeBanner.bind(this); | ||
this.someCustomAction = this.someCustomAction.bind(this); | ||
} | ||
|
||
public componentDidLoad() { | ||
this.banner = this.host.shadowRoot.querySelector('limel-banner'); | ||
} | ||
|
||
public render() { | ||
return [ | ||
<limel-button | ||
primary={true} | ||
disabled={this.disabled} | ||
label="Show Banner" | ||
onClick={this.openBanner} | ||
/>, | ||
<limel-banner message={this.message} icon="exclamation_mark"> | ||
<limel-flex-container | ||
justify="end" | ||
align="stretch" | ||
slot="buttons" | ||
> | ||
<limel-button | ||
label="Some Action" | ||
onClick={this.someCustomAction} | ||
/> | ||
<limel-button label="Close" onClick={this.closeBanner} /> | ||
</limel-flex-container> | ||
</limel-banner>, | ||
]; | ||
} | ||
|
||
private openBanner() { | ||
this.banner.open(); | ||
this.disabled = true; | ||
} | ||
|
||
private closeBanner() { | ||
this.banner.close(); | ||
this.disabled = false; | ||
} | ||
|
||
private someCustomAction() { | ||
alert('Triggered an action of some sort'); | ||
this.closeBanner(); | ||
} | ||
} |
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