Skip to content

Instantly share code, notes, and snippets.

@kyledurand
Created May 11, 2021 19:26
Show Gist options
  • Save kyledurand/c2d174f8e5b4db22e50236e052090943 to your computer and use it in GitHub Desktop.
Save kyledurand/c2d174f8e5b4db22e50236e052090943 to your computer and use it in GitHub Desktop.
Polaris / base web
import {ThemeProvider as PolarisThemeProvider} from '@shopify/polaris';
import {spacingBase, spacingTight} from '@shopify/polaris-tokens';
import {createTheme, ThemeProvider} from 'baseui';
import {styled} from 'styletron-react';
import {Card} from 'baseui/card';
import {Button, KIND} from 'baseui/button';
const primitives = {
text: 'var(--p-text-on-primary)',
primary: 'var(--p-action-primary)',
hover: 'var(--p-action-primary-hovered)',
active: 'var(--p-action-primary-pressed)',
};
const overrides = {
colors: {
buttonPrimaryFill: primitives.primary,
buttonPrimaryText: primitives.text,
buttonPrimaryHover: primitives.hover,
buttonPrimaryActive: primitives.active,
buttonPrimarySelectedFill: primitives.primary,
buttonPrimarySelectedText: primitives.text,
buttonPrimarySpinnerForeground: primitives.text,
buttonPrimarySpinnerBackground: primitives.primary,
},
};
const ButtonText = styled('span', {
fontSize: '15px',
lineHeight: '16px',
fontWeight: 'var(--p-button-font-weight)',
});
export default function Home() {
const lightTheme = createTheme(primitives, overrides);
return (
<PolarisThemeProvider>
<ThemeProvider theme={lightTheme}>
<Card>
<Button
kind={KIND.primary}
overrides={{
BaseButton: {
style: {
borderRadius: 'var(--p-border-radius-base)',
padding: `${spacingTight} ${spacingBase}`,
boxShadow: `var(--p-button-drop-shadow),var(--p-button-inner-shadow)`,
},
},
}}
>
<ButtonText>Polaris button</ButtonText>
</Button>
</Card>
</ThemeProvider>
</PolarisThemeProvider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment