Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PPDSC-2798): expose css variables #653

Merged
merged 36 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
48153c0
chore(PPDSC-2412): major version 7.0.1
Jan 31, 2023
e11d105
chore(PPDSC-2412): audio player styling changes (#592)
mstuartf Feb 6, 2023
cace3b9
feat(PPDSC-2782): changing dividerInverse color (#613)
Vanals Feb 7, 2023
e41002d
chore(PPDSC-2775): update accordion default styles (#602)
Xin00163 Feb 7, 2023
3a7aa01
fix(PPDSC-2779): Improve handling of OrderedList paragraph scenario (…
JohnTParsons Feb 8, 2023
ae7fdfa
chore(PPDSC-2723): update Slider component defaults (#606)
evgenitsn Feb 8, 2023
6955fda
chore(PPDSC-2776): update Link component defaults (#614)
mstuartf Feb 9, 2023
e741f68
feat(PPDSC-2726): update snap (#615)
Vanals Feb 9, 2023
5fc87fc
chore(PPDSC-2774): update Popover component defaults (#617)
evgenitsn Feb 10, 2023
5de6096
chore(PPDSC-2722): update Select component defaults (#608)
evgenitsn Feb 10, 2023
94bd6a0
chore(PPDSC-2725): banner (#607)
mstuartf Feb 10, 2023
cea9ece
Chore/ppdsc 2778 tag default styles (#622)
baburay23 Feb 13, 2023
7f7dcfd
merge
Feb 13, 2023
0141c91
feat(PPDSC-2781): update menu defaults (#616)
Xin00163 Feb 13, 2023
d2b137a
chore(PPDSC-2780): chore/ppdse-2780-titlebar-defaults fixed defaults …
baburay23 Feb 13, 2023
9e2ba2b
feat(PPDSC-1940): remove Link component (#624)
evgenitsn Feb 14, 2023
12e9ede
feat(PPDSC2091): caption refactoring (#627)
mutebg Feb 14, 2023
37fc708
feat(PPDSC-2798): add css variables
Feb 20, 2023
591e301
feat(PPDSC-2798): add files
Feb 20, 2023
c3870f0
feat(PPDSC-2798): add fonts
Feb 20, 2023
a235492
feat(PPDSC-2798): update site snapshots
Feb 21, 2023
2ecbf9a
feat(PPDSC-2422): update newskit light and dark theme tokens (#632)
evgenitsn Feb 21, 2023
42877f6
feat(PPDSC-2428): Popover Tooltip AudioPlayer override name (#641)
evgenitsn Feb 21, 2023
65b75d7
feat(PPDSC-2798): update docs
Feb 22, 2023
2cf8031
chore(PPDSC-1866): remove crop config (#625)
mstuartf Feb 22, 2023
9ae8c2d
feat(PPDSC-2798): update snapshots
Feb 22, 2023
f3269a7
feat(PPDSC-2798): fix coverage
Feb 22, 2023
b6ed58c
feat(PPDSC-2798): fixing tests
Feb 22, 2023
8d93b4f
feat(PPDSC-2798): fix tests
Feb 24, 2023
f0ea484
feat(PPDSC-2798): rename-var
Feb 24, 2023
f04c7a0
feat(PPDSC-2798): merge
Mar 1, 2023
fd542aa
feat(PPDSC-2798): update tests
Mar 1, 2023
cc19931
Merge branch 'main' into feat/PPDSC-2798-expose-css-variables
mutebg Mar 1, 2023
197634c
Merge branch 'main' into feat/PPDSC-2798-expose-css-variables
mutebg Mar 1, 2023
82fd7b4
feat(PPDSC-2798): updaate snapshots
Mar 1, 2023
bec34d0
feat(PPDSC-2798): updaate snapshots
Mar 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ Run this codemod if you would like to apply logical props instead.
+ <Block stylePreset="inkContrast" paddingBlock="space020" paddingInline="space020">Block</Block>
```


## Development

### Setup
Expand Down
1 change: 0 additions & 1 deletion site/components/theme-provider-site/index.ts

This file was deleted.

55 changes: 0 additions & 55 deletions site/components/theme-provider-site/theme-provider-site.tsx

This file was deleted.

16 changes: 7 additions & 9 deletions site/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {HeadNextSeo} from '../components/head-next-seo/head-next-seo';
import {PageLoadInstrumentation} from '../components/page-load-instrumentation';
import {ThemeMode} from '../context';
import {docsThemeLight, docsThemeDark} from '../theme/doc-theme';
import {ThemeProviderSite} from '../components/theme-provider-site';
import {transformEventObject} from '../utils/instrumentation';

const DARK_MEDIA_QUERY = '(prefers-color-scheme: dark)';
Expand Down Expand Up @@ -156,6 +155,7 @@ export default class MyApp extends App<Props, State> {

<NewsKitProvider
theme={theme}
themeOptions={{exposeCssVariables: true}}
layer={{zIndex: 1000}}
instrumentation={createEventInstrumentation(handlers, {
...pageProps,
Expand All @@ -165,14 +165,12 @@ export default class MyApp extends App<Props, State> {
>
<ThemeMode.Provider value={themeMode}>
<PageLoadInstrumentation />
<ThemeProviderSite theme={theme}>
<Component
{...pageProps}
path={path}
toggleTheme={this.toggleTheme}
themeMode={themeMode}
/>
</ThemeProviderSite>
<Component
{...pageProps}
path={path}
toggleTheme={this.toggleTheme}
themeMode={themeMode}
/>
</ThemeMode.Provider>
</NewsKitProvider>
</>
Expand Down
8 changes: 4 additions & 4 deletions site/pages/patterns/overview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {Grid} from 'newskit';
import {Grid, ThemeProvider} from 'newskit';
import {routes} from '../../routes';
import Layout, {LayoutProps} from '../../components/layout';
import {Item} from '../../components/sidebar/types';
Expand All @@ -16,7 +16,6 @@ import {
ContentPrimary,
ContentSection,
} from '../../components/content-structure';
import {ThemeProviderSite} from '../../components/theme-provider-site';

const patternsRouteList: Item[] =
routes.filter(route => route.title === 'Patterns')[0].subNav || [];
Expand Down Expand Up @@ -55,7 +54,8 @@ const HeaderImage = () => (
const Overview = (layoutProps: LayoutProps) => (
<Layout {...layoutProps} newPage>
{({themeMode}) => (
<ThemeProviderSite
<ThemeProvider
exposeCssVariables
theme={themeMode === 'light' ? patternsThemeLight : patternsThemeDark}
>
<HeadNextSeo
Expand Down Expand Up @@ -90,7 +90,7 @@ const Overview = (layoutProps: LayoutProps) => (
</ContentSection>
</ComponentPageCell>
</Grid>
</ThemeProviderSite>
</ThemeProvider>
)}
</Layout>
);
Expand Down
8 changes: 4 additions & 4 deletions site/pages/theme/overview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {Grid} from 'newskit';
import {Grid, ThemeProvider} from 'newskit';
import {
ContentPrimary,
ContentSection,
Expand All @@ -15,7 +15,6 @@ import {
} from '../../components/illustrations/illustration-loader';
import {Item} from '../../components/sidebar/types';
import {HeadNextSeo} from '../../components/head-next-seo';
import {ThemeProviderSite} from '../../components/theme-provider-site';
import {
foundationsThemeLight,
foundationsThemeDark,
Expand Down Expand Up @@ -61,7 +60,8 @@ enabling brands to retain a unique identity while building consistent, accessibl
const Overview = (layoutProps: LayoutProps) => (
<Layout {...layoutProps} newPage>
{({themeMode}) => (
<ThemeProviderSite
<ThemeProvider
exposeCssVariables
theme={
themeMode === 'light' ? foundationsThemeLight : foundationsThemeDark
}
Expand Down Expand Up @@ -118,7 +118,7 @@ const Overview = (layoutProps: LayoutProps) => (
</ContentSection>
</ComponentPageCell>
</Grid>
</ThemeProviderSite>
</ThemeProvider>
)}
</Layout>
);
Expand Down
27 changes: 26 additions & 1 deletion site/pages/theme/theming/using-a-theme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To render NewsKit components you must have a theme available for them to utilise

### NewsKitProvider & ThemeProvider components

NewsKitProvider provides a single wrapper to configure your application which includes ThemeProvider, <Link href="/components/utils/hooks/#usemediaqueryobject">MediaQueryProvider</Link>, <Link href="/getting-started/code/instrumentation/">InstrumentationProvider</Link> and LayerOrganizer.
NewsKitProvider provides a single wrapper to configure your application which includes ThemeProvider, <Link href="/components/utils/hooks/#usemediaqueryobject">MediaQueryProvider</Link>, <Link href="/getting-started/code/instrumentation/">InstrumentationProvider</Link> and <Link href="/components/layer/">LayerOrganizer</Link>.

A ThemeProvider utilises a React Context to provide a theme to all NewsKit components descended under it. You pass your theme (or a NewsKit default) to the `theme` prop. This will typically be an uncompiled theme, but you can pass a pre-compiled theme if you wish.

Expand Down Expand Up @@ -54,3 +54,28 @@ By wrapping your component in `withTheme`, the theme object will be passed into
The `useTheme` hook also allows you to access the theme, but helps avoid the extra "wrapper hell" that higher-order components bring.

<CodeFromFile path="examples/theming/use-theme.tsx" />

## Using CSS custom properties (variables)

NewsKit provides a way to expose the following tokens as CSS variables: `borders`, `colors`, `overlays`, `motions`, `shadows`, `sizing`, `spacePresets` and `fonts`.

Color tokens have prefix of `color` for example `inkBase` is `--color-inkBase`, the rest of the tokens are keeping their names like `sizing020` is `--sizing020`.

In order to enable that functionality to your project, you need to add a prop `exposeCssVariables` to ThemeProvider, or pass it as themeOptions to NewsKitProvider as the example bellow:

<Code>
{`<NewsKitProvider theme={yourTheme} themeOptions={{exposeCssVariables: true}}>
Main theme context

<ThemeProvider theme={yourSubTheme} exposeCssVariables>Sub-theme context</ThemeProvider>
</NewsKitProvider>`}
</Code>

<InlineMessage
overrides={{marginBlockStart: 'space030'}}
role="region"
aria-label="css variables"
>
Exposing CSS variables will add aditional <strong>div</strong> element to your
HTML
</InlineMessage>