-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(internet-header): expose CSS custom properties (#3200)
Co-authored-by: Philipp Gfeller <[email protected]>
- Loading branch information
1 parent
976c111
commit cf081ce
Showing
13 changed files
with
164 additions
and
15 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,6 @@ | ||
--- | ||
'@swisspost/internet-header': minor | ||
'@swisspost/design-system-documentation': minor | ||
--- | ||
|
||
Added a new stylesheet containing `:root` CSS custom properties to facilitate implementing styles relative to the header. This will allow putting sticky content right below the header. |
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
17 changes: 17 additions & 0 deletions
17
...mponents/internet-header/header/overrides-stories/header-css-variables.docs.mdx
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 { Meta, Canvas, Controls } from '@storybook/blocks'; | ||
import * as HeaderStories from './header-css-variables.stories'; | ||
import '../header.scss'; | ||
|
||
<Meta of={HeaderStories} /> | ||
|
||
<div className="container"> | ||
<h1>Internet Header CSS Variables</h1> | ||
<p className="lead">When you need to implement styling relative to the header.</p> | ||
</div> | ||
|
||
<Canvas sourceState='shown' of={HeaderStories.Default} /> | ||
|
||
## Style Imports | ||
|
||
To access the CSS variables for the header, you need to install an optional stylesheet into your project. | ||
Learn more in the <a href="/?path=/docs/cfa21cbc-5f8d-4a42-8165-7f6ed20bf133--docs#css-variables">header CSS variables stylesheet documentation</a>. |
32 changes: 32 additions & 0 deletions
32
...ories/components/internet-header/header/overrides-stories/header-css-variables.stories.ts
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,32 @@ | ||
import meta from '@/stories/components/internet-header/header/header.stories'; | ||
import * as HeaderStories from '@/stories/components/internet-header/header/header.stories'; | ||
import { Args } from '@storybook/web-components'; | ||
import { html } from 'lit'; | ||
|
||
export default { | ||
...HeaderStories.default, | ||
id: 'bfdf4e7c-37d3-40f8-a5d0-734f3e6612b5', | ||
title: 'Components/Internet Header/Header/CSS Variables', | ||
}; | ||
|
||
export const Default = { | ||
render: (args: Args, context: any) => { | ||
return html` | ||
<style> | ||
#my-div { | ||
z-index: 1000; | ||
top: 0; | ||
transition: var(--post-header-slide-in-transition); | ||
} | ||
swisspost-internet-header.scrolling-up + #my-div { | ||
top: var(--post-header-height); | ||
} | ||
</style> | ||
${meta.render && meta.render(args, context)} | ||
<p id="my-div" class="position-sticky bg-nightblue p-regular"> | ||
I am sticky! I am always positioned right below the header when you scroll up and down. | ||
</p> | ||
`; | ||
}, | ||
}; |
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
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
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
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
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,8 @@ | ||
@use 'utils/mixins'; | ||
@use 'utils/variables'; | ||
|
||
:root { | ||
@include mixins.set-custom-property(--post-meta-header-height, variables.$meta-header-height); | ||
@include mixins.set-custom-property(--post-header-height, variables.$header-height); | ||
@include mixins.set-custom-property(--post-header-slide-in-transition, variables.$header-slide-in-transition); | ||
} |
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
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,21 @@ | ||
$meta-header-height: ( | ||
xs: 0px, | ||
sm: 0px, | ||
rg: 0px, | ||
md: 0px, | ||
lg: 3rem, | ||
xl: 3rem, | ||
xxl: 3rem, | ||
); | ||
|
||
$header-height: ( | ||
xs: 3.5rem, | ||
sm: 3.5rem, | ||
rg: 3.5rem, | ||
md: 3.5rem, | ||
lg: 4rem, | ||
xl: 4.5rem, | ||
xxl: 4.5rem, | ||
); | ||
|
||
$header-slide-in-transition: top 200ms ease-out; |
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 @@ | ||
import { Config } from '@stencil/core'; | ||
import { sass } from '@stencil/sass'; | ||
import { config as prodConfig } from './stencil.config'; | ||
|
||
export const config: Config = { | ||
...prodConfig, | ||
globalStyle: 'src/styles.scss', | ||
plugins: [ | ||
sass({ | ||
includePaths: ['node_modules'], | ||
}), | ||
], | ||
}; |
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