Skip to content

Commit addfb78

Browse files
authored
Merge pull request #298 from codesnippetspro/rtl
Migrate to native CSS direction management
2 parents 8f86319 + 8c04498 commit addfb78

File tree

12 files changed

+23
-97
lines changed

12 files changed

+23
-97
lines changed

config/RtlCssPlugin.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

config/webpack-css.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import hslCompat from 'postcss-color-hsl'
77
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
88
import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts'
99
import { glob } from 'glob'
10-
import { RtlCssPlugin } from './RtlCssPlugin'
1110
import type { Configuration, EntryObject } from 'webpack'
1211
import type { Config as PostCssConfig } from 'postcss-load-config'
1312

@@ -103,9 +102,6 @@ export const cssWebpackConfig: Configuration = {
103102
.replace(/^codemirror-theme-/, 'editor-themes/')
104103
.replace(/-css\.css$/, '.css')
105104
: '[name].css'
106-
}),
107-
new RtlCssPlugin({
108-
entries: new Set(['manage-css', 'edit-css'])
109105
})
110106
]
111107
}

package-lock.json

Lines changed: 0 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
"@types/prismjs": "^1.26.5",
7474
"@types/react": "^18.3.1",
7575
"@types/react-dom": "^18.3.1",
76-
"@types/rtlcss": "^3.5.4",
7776
"@types/tinymce": "^4.6.9",
7877
"@types/web": "^0.0.202",
7978
"@typescript-eslint/eslint-plugin": "^8.24.0",
@@ -100,7 +99,6 @@
10099
"postcss-load-config": "^6.0.1",
101100
"postcss-loader": "^8.1.1",
102101
"react-is": "^19.0.0",
103-
"rtlcss": "^4.3.0",
104102
"sass": "^1.84.0",
105103
"sass-loader": "^16.0.4",
106104
"style-loader": "^4.0.0",

src/css/common/_direction.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:root {
2+
--cs-direction-multiplier: 1; // LTR = 1, RTL = -1
3+
}
4+
5+
html[dir="rtl"],
6+
body.rtl {
7+
--cs-direction-multiplier: -1;
8+
}

src/css/common/_switch.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ input[type='checkbox'].switch:checked {
4040

4141
&::before {
4242
background-color: white;
43-
transform: translateX(100%);
43+
transform: translateX(calc(100% * var(--cs-direction-multiplier)));
4444
}
4545
}
4646

4747
.erroneous-snippet .snippet-activation-switch::before {
4848
content: '!';
49-
transform: translateX(50%);
49+
transform: translateX(calc(50% * var(--cs-direction-multiplier)));
5050
text-align: center;
5151
font-weight: bold;
5252
line-height: 1;

src/css/common/_tooltips.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ $bg-color: hsl(0deg 0% 20% / 90%);
172172
.tooltip-inline.tooltip-end:hover,
173173
.tooltip-inline.tooltip-end:focus {
174174
&::before, .tooltip-content {
175-
transform: translateX(10px);
175+
transform: translateX(calc(10px * var(--cs-direction-multiplier)));
176176
}
177177
}
178178

179179
.tooltip-inline.tooltip-start:hover,
180180
.tooltip-inline.tooltip-start:focus {
181181
&::before, .tooltip-content {
182-
transform: translateX(-10px);
182+
transform: translateX(calc(-10px * var(--cs-direction-multiplier)));
183183
}
184184
}

src/css/edit.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Styles for the edit snippet admin page.
33
*/
44

5+
@use 'common/direction';
56
@use 'common/codemirror';
67
@use 'common/badges';
78
@use 'common/switch';

src/css/manage/_cloud.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ td.column-download {
237237
gap: 5px;
238238
}
239239

240-
241240
.cloud-table > tbody > tr {
242241
block-size: 80px;
243242
box-shadow: inset 0 -1px 0 rgb(0 0 0 / 10%);
@@ -265,7 +264,6 @@ td.column-download {
265264
background-color: #ce0000;
266265
border-radius: 50%;
267266

268-
269267
.cloud-connect-active & {
270268
background-color: #25a349;
271269
}
@@ -284,6 +282,10 @@ td.column-download {
284282
block-size: 1.25rem; /* 20px */
285283
transform-origin: bottom left;
286284

285+
[dir="rtl"] & {
286+
transform-origin: bottom right;
287+
}
288+
287289
&:hover {
288290
stroke: #059669;
289291
fill: #6ee7b7;
@@ -325,15 +327,15 @@ td.column-download {
325327
}
326328

327329
33% {
328-
transform: rotate(7deg)
330+
transform: rotate(calc(7deg * var(--cs-direction-multiplier)));
329331
}
330332

331333
66% {
332-
transform: rotate(-15deg)
334+
transform: rotate(calc(-15deg * var(--cs-direction-multiplier)));
333335
}
334336

335337
90% {
336-
transform: rotate(5deg)
338+
transform: rotate(calc(5deg * var(--cs-direction-multiplier)));
337339
}
338340

339341
100% {

src/css/welcome.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,6 @@ a.csp-card {
378378

379379
@keyframes loading-rotate {
380380
100% {
381-
transform: rotate(360deg);
381+
transform: rotate(calc(360deg * var(--cs-direction-multiplier)));
382382
}
383383
}

0 commit comments

Comments
 (0)