Skip to content

Commit 1644fd9

Browse files
committed
Update Playground with the latest changes in version 5.0.0
1 parent de125df commit 1644fd9

File tree

3 files changed

+37
-31
lines changed

3 files changed

+37
-31
lines changed

playground/src/components/AppProvider/AppProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PropsWithChildren, createContext, useContext, useState, useEffect } from 'react';
2-
import { Mode, Source, Autorename } from 'postcss-rtlcss/options';
2+
import { Mode, Source } from 'postcss-rtlcss/options';
33
import { PluginOptions, FetchOptions } from '@types';
44
import { breakpointSizes } from '@constants';
55
import { useApi } from '@hooks/useApi';
@@ -31,10 +31,10 @@ export interface AppProviderContext {
3131
changeOptionsSafeBothPrefix: (safeBothPrefix: boolean) => void;
3232
changeOptionsIgnorePrefixedRules: (ignorePrefixedRules: boolean) => void;
3333
changeOptionsProcessUrls: (processUrls: boolean) => void;
34+
changeOptionsProcessRuleNames: (processRuleNames: boolean) => void;
3435
changeOptionsProcessKeyframes: (processKeyFrames: boolean) => void;
3536
changeOptionsProcessEnv: (processEnv: boolean) => void;
3637
changeOptionsUseCalc: (useCalc: boolean) => void;
37-
changeOptionsAutoRename: (value: Autorename) => void;
3838
changeOptionsGreedy: (greedy: boolean) => void;
3939
}
4040

@@ -94,10 +94,10 @@ export const AppProvider = (props: PropsWithChildren<{}>): JSX.Element => {
9494
const changeOptionsSafeBothPrefix = (safeBothPrefix: boolean): void => setOptions({...options, safeBothPrefix});
9595
const changeOptionsIgnorePrefixedRules = (ignorePrefixedRules: boolean) => setOptions({...options, ignorePrefixedRules});
9696
const changeOptionsProcessUrls = (processUrls: boolean): void => setOptions({ ...options, processUrls });
97+
const changeOptionsProcessRuleNames = (processRuleNames: boolean): void => setOptions({ ...options, processRuleNames });
9798
const changeOptionsProcessKeyframes = (processKeyFrames: boolean): void => setOptions({ ...options, processKeyFrames });
9899
const changeOptionsProcessEnv = (processEnv: boolean): void => setOptions({ ...options, processEnv });
99100
const changeOptionsUseCalc = (useCalc: boolean): void => setOptions({ ...options, useCalc });
100-
const changeOptionsAutoRename = (value: Autorename): void => setOptions({ ...options, autoRename: value });
101101
const changeOptionsGreedy = (greedy: boolean): void => setOptions({ ...options, greedy });
102102

103103
const providerData = {
@@ -118,10 +118,10 @@ export const AppProvider = (props: PropsWithChildren<{}>): JSX.Element => {
118118
changeOptionsSafeBothPrefix,
119119
changeOptionsIgnorePrefixedRules,
120120
changeOptionsProcessUrls,
121+
changeOptionsProcessRuleNames,
121122
changeOptionsProcessKeyframes,
122123
changeOptionsProcessEnv,
123124
changeOptionsUseCalc,
124-
changeOptionsAutoRename,
125125
changeOptionsGreedy,
126126
windowSizes: sizes
127127
};

playground/src/components/Options/Options.tsx

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect } from 'react';
2-
import { Mode, Source, Autorename } from 'postcss-rtlcss/options';
2+
import { Mode, Source } from 'postcss-rtlcss/options';
33
import { useAppContext } from '@components/AppProvider';
44
import { Switch } from '@components/Switch';
55
import { SwitchGroup } from '@components/SwitchGroup';
@@ -16,10 +16,10 @@ export const Options = (): JSX.Element => {
1616
changeOptionsSafeBothPrefix,
1717
changeOptionsIgnorePrefixedRules,
1818
changeOptionsProcessUrls,
19+
changeOptionsProcessRuleNames,
1920
changeOptionsProcessKeyframes,
2021
changeOptionsProcessEnv,
2122
changeOptionsUseCalc,
22-
changeOptionsAutoRename,
2323
changeOptionsGreedy,
2424
fetchOptions
2525
} = useAppContext();
@@ -37,18 +37,10 @@ export const Options = (): JSX.Element => {
3737
const changeSafeBothPrefix = (checked: boolean) => changeOptionsSafeBothPrefix(checked);
3838
const changeIgnorePrefixedRules = (checked: boolean) => changeOptionsIgnorePrefixedRules(checked);
3939
const changeProcessUrls = (checked: boolean): void => changeOptionsProcessUrls(checked);
40+
const changeProcessRuleNames = (processRuleNames: boolean): void => changeOptionsProcessRuleNames(processRuleNames);
4041
const changeProcessKeyframes = (checked: boolean): void => changeOptionsProcessKeyframes(checked);
4142
const changeProcessEnv = (checked: boolean): void => changeOptionsProcessEnv(checked);
4243
const changeUseCalc = (checked: boolean): void => changeOptionsUseCalc(checked);
43-
const changeAutoRename = (value: string): void => {
44-
if (value === 'disabled') {
45-
changeOptionsAutoRename(Autorename.disabled);
46-
} else if (value === 'flexible') {
47-
changeOptionsAutoRename(Autorename.flexible);
48-
} else {
49-
changeOptionsAutoRename(Autorename.strict);
50-
}
51-
};
5244
const changeGreedy = (checked: boolean): void => changeOptionsGreedy(checked);
5345

5446
useEffect(() => {
@@ -117,6 +109,16 @@ export const Options = (): JSX.Element => {
117109
}}
118110
/>
119111
</div>
112+
{ /* processRuleNames */ }
113+
<div className={styles.panel}>
114+
<Switch
115+
labels={['processRuleNames: false', 'processRuleNames: true']}
116+
onChange={changeProcessRuleNames}
117+
attributes={{
118+
checked: !!fetchOptions?.processRuleNames
119+
}}
120+
/>
121+
</div>
120122
{ /* processKeyFrames */ }
121123
<div className={styles.panel}>
122124
<Switch
@@ -151,16 +153,6 @@ export const Options = (): JSX.Element => {
151153
}}
152154
/>
153155
</div>
154-
{ /* autoRename */ }
155-
<div className={styles.panel}>
156-
<SwitchGroup
157-
label="autoRename"
158-
name="auto-rename"
159-
values={['disabled', 'flexible', 'strict']}
160-
onChange={changeAutoRename}
161-
active={fetchOptions?.autoRename as string || 'disabled'}
162-
/>
163-
</div>
164156
{ /* greedy */ }
165157
<div className={styles.panel}>
166158
<Switch

playground/src/components/Playground/css.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,44 @@ export const cssLines = `.test1, .test2 {
5858
}
5959
}
6060
61-
/*rtl:rename*/
6261
.test10-ltr {
6362
color: #000;
6463
width: 100%;
6564
}
6665
6766
.test11-left::before {
68-
content: "keyboard_arrow_left";
67+
background-image: url("/icons/icon-l.png");
6968
}
7069
7170
.test11-right::before {
72-
content: "keyboard_arrow_right";
71+
background-image: url("/icons/icon-r.png");
7372
}
7473
7574
.testleft12 {
76-
border: 1px solid gray;
75+
content: "\\f007";
76+
}
77+
78+
.testright12 {
79+
content: "\\f010";
7780
}
7881
79-
.testleft13 {
82+
.testltr13 {
8083
content: "keyboard_arrow_left";
8184
}
8285
83-
.testright14 {
86+
.testrtl13 {
8487
content: "keyboard_arrow_right";
8588
}
8689
90+
.test14 {
91+
.test14-ltr {
92+
content: "left content";
93+
}
94+
.test14-rtl {
95+
content: "right content";
96+
}
97+
}
98+
8799
.test15 {
88100
color: #EFEFEF;
89101
left: 10px;
@@ -142,6 +154,8 @@ export const cssLines = `.test1, .test2 {
142154
}
143155
144156
.test22 {
157+
/*rtl:urls*/
158+
background: url("/folder/icons/icon-ltr.png");
145159
margin-right: env(safe-area-inset-right, 10px);
146160
margin-left: env(safe-area-inset-left, 20px);
147161
}

0 commit comments

Comments
 (0)