Skip to content

Commit 817b94f

Browse files
committed
fix css
1 parent c5abc1a commit 817b94f

File tree

10 files changed

+464
-524
lines changed

10 files changed

+464
-524
lines changed

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"start": "wp-scripts start",
1515
"test:e2e": "wp-scripts test-playwright",
1616
"test:js": "wp-scripts test-unit-js",
17+
"test:js:update": "wp-scripts test-unit-js --updateSnapshot",
1718
"test:performance": "wp-scripts test-playwright --config tests/performance/playwright.config.ts",
1819
"test:performance:merge-reports": "playwright merge-reports --reporter tests/performance/config/performance-reporter.ts ./blob-report",
1920
"test:performance:results": "node tests/performance/cli/results.js",
@@ -29,6 +30,7 @@
2930
},
3031
"dependencies": {
3132
"@testing-library/user-event": "^14.5.2",
33+
"@types/react-highlight": "^0.12.8",
3234
"@wordpress/api-fetch": "^6.48.0",
3335
"@wordpress/components": "^27.1.0",
3436
"@wordpress/data": "^9.23.0",
@@ -39,7 +41,9 @@
3941
"dotenv": "^16.4.5",
4042
"react": "18.2.0",
4143
"react-dom": "18.2.0",
42-
"react-syntax-highlighter": "^15.5.0",
44+
"react-highlight": "^0.15.0",
45+
"react-highlight-syntax": "^1.2.1",
46+
"react-syntax-highlighter": "^15.4.3",
4347
"react-test-renderer": "^18.2.0",
4448
"ts-loader": "^9.5.1",
4549
"typescript": "^5.4.2"
@@ -50,7 +54,7 @@
5054
"@testing-library/react": "14.2.2",
5155
"@types/jest": "^29.5.12",
5256
"@types/node": "^20.12.5",
53-
"@types/react-syntax-highlighter": "^15.5.11",
57+
"@types/react-syntax-highlighter": "15.5.6",
5458
"@types/wordpress__components": "^23.0.11",
5559
"@wordpress/e2e-test-utils-playwright": "^0.22.0",
5660
"@wordpress/env": "^9.7.0",

src/components/snippets/JsSnippet.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Snippet from './Snippet';
22
import { useMemo } from '@wordpress/element';
33
import { __ } from '@wordpress/i18n';
4-
import Clipboard from '../common/Clipboard';
54

65
const JsSnippet = ({ flag }: { flag: string }) => {
76
const jsSnippet = useMemo(() => {
@@ -18,8 +17,7 @@ domReady(function () {
1817
return (
1918
<div className="mr-feature-flag-js-snippet-container">
2019
<h3>{__('JavaScript Snippet', 'codeb-feature-flags')}</h3>
21-
<Clipboard text={jsSnippet} />
22-
<Snippet data={jsSnippet} language={'typescript'} />
20+
<Snippet data={jsSnippet} language="JavaScript" />
2321
</div>
2422
);
2523
};

src/components/snippets/PhpSnippet.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Snippet from './Snippet';
22
import { useMemo } from '@wordpress/element';
33
import { __ } from '@wordpress/i18n';
4-
import Clipboard from '../common/Clipboard';
54

65
const PhpSnippet = ({ flag }: { flag: string }) => {
76
const phpSnippet = useMemo(() => {
@@ -13,8 +12,7 @@ if ( class_exists( '\\CodeB\\FeatureFlags\\Flag' ) && Flag::is_enabled( '${flag}
1312
return (
1413
<div className="mr-feature-flag-php-snippet-container">
1514
<h3>{__('PHP Snippet', 'codeb-feature-flags')}</h3>
16-
<Clipboard text={phpSnippet} />
17-
<Snippet data={phpSnippet} language={'php'} />
15+
<Snippet data={phpSnippet} language="PHP" />
1816
</div>
1917
);
2018
};

src/components/snippets/Snippet.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import SyntaxHighlighter from 'react-syntax-highlighter';
2-
import { a11yDark } from 'react-syntax-highlighter/dist/cjs/styles/hljs';
1+
import ReactHighlightSyntax from 'react-highlight-syntax';
2+
import type { Language } from 'react-highlight-syntax';
33

4-
const Snippet = ({
5-
data,
6-
language,
7-
}: {
8-
data: string;
9-
language: string;
10-
}): JSX.Element => {
4+
const Snippet = ({ data, language }: { data: string; language: Language }) => {
115
return (
12-
<SyntaxHighlighter language={language} style={a11yDark}>
6+
<ReactHighlightSyntax
7+
theme={'Base16Darcula'}
8+
language={language}
9+
copy={true}
10+
copyBtnTheme={'Dark'}
11+
>
1312
{data}
14-
</SyntaxHighlighter>
13+
</ReactHighlightSyntax>
1514
);
1615
};
1716

src/components/snippets/TsSupport.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { useMemo } from '@wordpress/element';
22
import { __ } from '@wordpress/i18n';
3-
import Clipboard from '../common/Clipboard';
4-
53
import Snippet from './Snippet';
64

75
const TsSupport = (): JSX.Element => {
@@ -30,8 +28,7 @@ export {};`;
3028
<span className="codeb-feature-flags-slug"> src</span> directory
3129
) and add the following declaration.
3230
</p>
33-
<Clipboard text={tsSnippet} />
34-
<Snippet data={tsSnippet} language={'typescript'} />
31+
<Snippet data={tsSnippet} language="TypeScript" />
3532
</div>
3633
);
3734
};

0 commit comments

Comments
 (0)