Skip to content

Commit 43a5453

Browse files
authored
Merge pull request #20 from silinternational/feature/TopAppBar-story
TopAppBar story
2 parents 4042db2 + 37214f5 commit 43a5453

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- actions, isAboveMobile, isAboveTablet, setNotice to index.js so they can be imported directly
1313
- $$props.class to Fab, TextArea, Select, Checkbox and List so they can accept global classes
1414
- barColorProvided to Progress.Linear to allow bypass of bar-color class when no color is provided
15-
- README: Theming, Drawer example and Storybook url.
15+
- bgColorIsVariant to TopAppBar to allow bypass of bg-color-variant if no color is provided
16+
- README: Theming, Drawer example, CSS utility classes and Storybook url.
1617
- Storybook for showcasing components at https://silinternational.github.io/ui-components/
1718
1819
### Fixed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Tooltip (tooltipID, positionX, positionY) [
9090
Tooltip.Wrapper (ariaDescribedBy)
9191
]
9292

93-
TopAppBar (dense, fixed, navIconBreakpointClass) [
93+
TopAppBar (dense, fixed, navIconBreakpointClass, bgColorIsVariant) [
9494
actions.js, title.js
9595
]
9696

@@ -179,7 +179,10 @@ An example of using Drawer:
179179
```
180180

181181
### storybook
182-
Check out our components at https://silinternational.github.io/ui-components/
182+
Try out our components at https://silinternational.github.io/ui-components/
183+
184+
### CSS utility classes
185+
Classes from [global.css](https://github.com/silinternational/ui-components/blob/develop/components/global.css) can be applied to all components and even components and elements from your app.
183186

184187
### theming
185-
If you are using an MDC theme https://material.io/develop/web/docs/theming and typography https://material.io/develop/web/components/typography then import your _index.scss file to the App.svelte file so they get applied to the ui-components.
188+
If you are using an [MDC theme](https://material.io/develop/web/docs/theming) and [typography](https://material.io/develop/web/components/typography) then import your _index.scss file to the App.svelte file so they get applied to the ui-components.

components/mdc/TopAppBar/TopAppBar.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { MDCTopAppBar } from '@material/top-app-bar'
55
import { createEventDispatcher, onMount } from 'svelte'
66
import title from './title'
77
8+
export let bgColorIsVariant = true
89
export let dense = false
910
export let fixed = false
1011
export let navIconBreakpointClass = ''
@@ -23,15 +24,16 @@ onMount(() => {
2324
</script>
2425

2526
<style>
26-
header {
27-
position: absolute;
27+
.bg-color-variant {
2828
background-color: var(--mdc-theme-primary-variant); /* had to override this because we're going against the MDC spec that the top app bar should be the primary color. */
2929
}
3030
</style>
3131

32-
<header class="mdc-top-app-bar"
32+
<header class="mdc-top-app-bar absolute"
3333
class:mdc-top-app-bar--dense={dense}
34-
class:mdc-top-app-bar--fixed={fixed} bind:this={element}>
34+
class:mdc-top-app-bar--fixed={fixed}
35+
class:bg-color-variant={bgColorIsVariant}
36+
bind:this={element}>
3537
<div class="mdc-top-app-bar__row">
3638
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
3739
<button class="material-icons mdc-top-app-bar__navigation-icon mdc-icon-button {navIconBreakpointClass}" aria-label="Open navigation menu">menu</button>

stories/TopAppBar.stories.svelte

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script>
2+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf"
3+
import { TopAppBar } from "../components/mdc"
4+
import { copyAndModifyArgs } from "./helpers.js"
5+
6+
const args = {
7+
class: '', //only works for global classes
8+
bgColorIsVariant: false,
9+
onNav: () => {},
10+
}
11+
</script>
12+
13+
<Meta
14+
title="Atoms/TopAppBar"
15+
component={TopAppBar}
16+
/>
17+
18+
<Template let:args>
19+
<TopAppBar {...args} on:nav={args.onNav}/>
20+
</Template>
21+
22+
<Story
23+
name="Default"
24+
{args}
25+
/>
26+
27+
<Story
28+
name="Dense"
29+
args={copyAndModifyArgs(args, {dense: true})}
30+
/>
31+
32+
<Story
33+
name="Fixed"
34+
args={copyAndModifyArgs(args, {fixed: true})}
35+
/>
36+
37+
<Story
38+
name="Hide above tablet"
39+
args={copyAndModifyArgs(args, {navIconBreakpointClass: "hide-above-tablet"})}
40+
/>

0 commit comments

Comments
 (0)