Skip to content

Commit 93a0aae

Browse files
committedMar 17, 2022
remove hacks, they seem to not be working
1 parent ea54b12 commit 93a0aae

File tree

3 files changed

+17
-38
lines changed

3 files changed

+17
-38
lines changed
 

‎packages/docusaurus-theme-redoc/src/theme/Redoc/ServerStyles.tsx

+16-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { AppStore, Redoc } from 'redoc';
33
// eslint-disable-next-line import/no-extraneous-dependencies
44
import { renderToString } from 'react-dom/server';
55
import { ServerStyleSheet } from 'styled-components';
6-
import { OnlyOnClient } from '../../utils/OnlyOnClient';
76

87
/**
98
* @see https://stackoverflow.com/a/54077142
@@ -59,29 +58,38 @@ export function ServerStyles({
5958
lightStore: AppStore;
6059
darkStore: AppStore;
6160
}) {
61+
const css = {
62+
light: '',
63+
dark: '',
64+
};
6265
const lightSheet = new ServerStyleSheet();
6366
renderToString(
6467
lightSheet.collectStyles(React.createElement(Redoc, { store: lightStore })),
6568
);
6669
const lightCss = lightSheet.getStyleTags();
67-
const lightModeOnlyCss = prefixCssSelectors(
68-
lightCss,
69-
LIGHT_MODE_PREFIX,
70-
).slice(LIGHT_MODE_PREFIX.length + 1);
70+
css.light = prefixCssSelectors(lightCss, LIGHT_MODE_PREFIX).slice(
71+
LIGHT_MODE_PREFIX.length + 1,
72+
);
7173

7274
const darkSheet = new ServerStyleSheet();
7375
renderToString(
7476
darkSheet.collectStyles(React.createElement(Redoc, { store: darkStore })),
7577
);
7678
const darkCss = darkSheet.getStyleTags();
77-
const darkModeOnlyCss = prefixCssSelectors(darkCss, DARK_MODE_PREFIX).slice(
79+
css.dark = prefixCssSelectors(darkCss, DARK_MODE_PREFIX).slice(
7880
DARK_MODE_PREFIX.length + 1,
7981
);
8082

8183
return (
8284
<div className="redocusaurus-styles">
83-
<OnlyOnClient key="light-mode-styles" html={lightModeOnlyCss} />
84-
<OnlyOnClient key="dark-mode-styles" html={darkModeOnlyCss} />
85+
<div
86+
key="light-mode-styles"
87+
dangerouslySetInnerHTML={{ __html: css.light }}
88+
/>
89+
<div
90+
key="dark-mode-styles"
91+
dangerouslySetInnerHTML={{ __html: css.dark }}
92+
/>
8593
</div>
8694
);
8795
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import type { AppStore } from 'redoc';
3-
import { OnlyOnClient } from '../../utils/OnlyOnClient';
43

54
/**
65
* Don't hydrate/replace server styles
@@ -10,16 +9,5 @@ export function ServerStyles(_props: {
109
lightStore: AppStore;
1110
darkStore: AppStore;
1211
}) {
13-
return (
14-
<div className="redocusaurus-styles">
15-
<OnlyOnClient
16-
key="light-mode-styles"
17-
html={`<style data-styled="true" data-styled-version="5.3.3"> test{} </style>`}
18-
/>
19-
<OnlyOnClient
20-
key="dark-mode-styles"
21-
html={`<style data-styled="true" data-styled-version="5.3.3"> test{} </style>`}
22-
/>
23-
</div>
24-
);
12+
return <div className="redocusaurus-styles"></div>;
2513
}

‎packages/docusaurus-theme-redoc/src/utils/OnlyOnClient.tsx

-17
This file was deleted.

0 commit comments

Comments
 (0)