Skip to content

Commit

Permalink
Use logical properties for space/divide in Oxide
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Jan 13, 2023
1 parent cbc5f98 commit fb326c8
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 858 deletions.
22 changes: 22 additions & 0 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs'
import * as path from 'path'
import postcss from 'postcss'
import { env } from './lib/sharedState'
import createUtilityPlugin from './util/createUtilityPlugin'
import buildMediaQuery from './util/buildMediaQuery'
import escapeClassName from './util/escapeClassName'
Expand Down Expand Up @@ -1219,6 +1220,16 @@ export let corePlugins = {
'space-x': (value) => {
value = value === '0' ? '0px' : value

if (env.OXIDE) {
return {
'& > :not([hidden]) ~ :not([hidden])': {
'--tw-space-x-reverse': '0',
'margin-inline-end': `calc(${value} * var(--tw-space-x-reverse))`,
'margin-inline-start': `calc(${value} * calc(1 - var(--tw-space-x-reverse)))`,
},
}
}

return {
'& > :not([hidden]) ~ :not([hidden])': {
'--tw-space-x-reverse': '0',
Expand Down Expand Up @@ -1254,6 +1265,17 @@ export let corePlugins = {
'divide-x': (value) => {
value = value === '0' ? '0px' : value

if (env.OXIDE) {
return {
'& > :not([hidden]) ~ :not([hidden])': {
'@defaults border-width': {},
'--tw-divide-x-reverse': '0',
'border-inline-end-width': `calc(${value} * var(--tw-divide-x-reverse))`,
'border-inline-start-width': `calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`,
},
}
}

return {
'& > :not([hidden]) ~ :not([hidden])': {
'@defaults border-width': {},
Expand Down
6 changes: 3 additions & 3 deletions tests/kitchen-sink.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@
font-weight: 400;
}
.list > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
--tw-space-y-reverse: 0;
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
}
.nested {
.example {
Expand Down
2 changes: 1 addition & 1 deletion tests/kitchen-sink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ test.each([[true], [false]])('it works (using Rust: %p)', (useOxide) => {
@apply font-bold group-hover:font-normal;
}
.list {
@apply space-x-4;
@apply space-y-4;
}
.nested {
.example {
Expand Down
Loading

0 comments on commit fb326c8

Please sign in to comment.