Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gpbl/react-day-picker
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Sep 8, 2022
2 parents 2f4d951 + 2238bcf commit 927ecb9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
12 changes: 10 additions & 2 deletions packages/react-day-picker/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,21 @@ const buildConfig = {
src: './src/style.css',
dest: './dist',
rename: 'style.module.css',
transform: (contents) => contents.toString().replace(/\.rdp-/g, '.')
transform: (contents) =>
contents
.toString()
.replace(/\.rdp-/g, '.')
.replace(/\.rdp/g, '.root')
},
{
src: './src/style.css.d.ts',
dest: './dist',
rename: 'style.module.css.d.ts',
transform: (contents) => contents.toString().replace(/rdp-/g, '')
transform: (contents) =>
contents
.toString()
.replace(/\.rdp-/g, '.')
.replace(/\.rdp/g, '.root')
}
]
})
Expand Down
21 changes: 16 additions & 5 deletions website/src/components/RenderExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ import BrowserOnly from '@docusaurus/BrowserOnly';
import { useColorMode } from '@docusaurus/theme-common';
import root from 'react-shadow';

const style: string = require(`!raw-loader!./shadow-dom-styles.css`).default;
const styleDark: string =
require(`!raw-loader!./shadow-dom-styles-dark.css`).default;
const libStyle: string =
require(`!raw-loader!react-day-picker/dist/style.css`).default;
const libStyleModule =
require(`react-day-picker/dist/style.module.css`).default;

let libStyleModuleRaw: string =
require(`!raw-loader!react-day-picker/dist/style.module.css`).default;
Object.entries(libStyleModule).map(([key, value]) => {
const regExp = new RegExp(`\\.${key}([,: .])+`, 'g');
libStyleModuleRaw = libStyleModuleRaw.replace(regExp, `.${value}$1`);
});

export function RenderExample(props: {
name: string;
rootStyle?: React.CSSProperties;
Expand All @@ -19,15 +34,11 @@ export function RenderExample(props: {
return <pre>{e.message}</pre>;
}
const Component = require(`@site/examples/${props.name}`).default;
const libStyle =
require(`!raw-loader!react-day-picker/dist/style.css`).default;
const style = require(`!raw-loader!./shadow-dom-styles.css`).default;
const styleDark =
require(`!raw-loader!./shadow-dom-styles-dark.css`).default;

return (
<root.div style={props.rootStyle}>
<style type="text/css">{libStyle}</style>
<style type="text/css">{libStyleModuleRaw}</style>
<style type="text/css">{style}</style>
<style type="text/css">{isDarkTheme && styleDark}</style>
<Component />
Expand Down

0 comments on commit 927ecb9

Please sign in to comment.