Skip to content

Commit

Permalink
Add logical properties support for inline direction (#10166)
Browse files Browse the repository at this point in the history
* ensure we use `npm@7` for older versions of Node.js

This is important so that we can guarantee that `workspaces` are
supported which we depend on right now (just for install purposes).

* tmp: trigger CI build (GitHub is doing funky things and not working right now)

* drop Node.js 12 from Node.js CI workflow

* focus on Node.js 16 for now

* Revert "tmp: trigger CI build (GitHub is doing funky things and not working right now)"

This reverts commit a3deed4.

* WIP

* Add support for logical properties in inline direction

* Add scroll-margin/scroll-padding utilities

* Update CHANGELOG

* Rename inset-s/e to start/end

* Update sort order in test

* Use logical properties for space/divide in Oxide

* run non-oxide and OXIDE tests

+ fix oxide version tests

* drop oxide specific test job

The normal `npm run test` will already include the non-oxide and oxide
version when running tests.

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 16, 2023
1 parent d0ecd29 commit 9e34619
Show file tree
Hide file tree
Showing 20 changed files with 5,323 additions and 1,442 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

strategy:
matrix:
node-version: [12, 14, 16, 18]
node-version: [16]

steps:
- uses: actions/checkout@v3
Expand All @@ -33,6 +33,10 @@ jobs:
node-version: ${{ matrix.node-version }}
# cache: 'npm'

- name: Install newer version of npm on older versions of Node.js
if: matrix.node-version < 16
run: npm install -g npm@7

- name: Cache node_modules
uses: actions/cache@v3
with:
Expand All @@ -57,12 +61,9 @@ jobs:
- name: Build Tailwind CSS
run: npx turbo run oxide:build --filter=//

- name: Test (default)
- name: Test
run: npx turbo run test --filter=//

- name: Test (oxide)
run: OXIDE=1 npx turbo run test --filter=//

lint:
runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `--watch=always` option to prevent exit when stdin closes ([#9966](https://github.com/tailwindlabs/tailwindcss/pull/9966))
- Add standalone CLI build for 64-bit Windows on ARM (`node16-win-arm64`) ([#10001](https://github.com/tailwindlabs/tailwindcss/pull/10001))
- Add `delay-0` and `duration-0` by default ([#10294](https://github.com/tailwindlabs/tailwindcss/pull/10294))
- Add logical properties support for inline direction ([#10166](https://github.com/tailwindlabs/tailwindcss/pull/10166))

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"rebuild-fixtures": "npm run build && node -r @swc/register scripts/rebuildFixtures.js",
"style": "eslint .",
"pretest": "npm run generate",
"test": "jest",
"test": "jest && OXIDE=1 jest",
"test:integrations": "npm run test --prefix ./integrations",
"install:integrations": "node scripts/install-integrations.js",
"generate:plugin-list": "node -r @swc/register scripts/create-plugin-list.js",
Expand Down
66 changes: 66 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 @@ -623,6 +624,8 @@ export let corePlugins = {
['inset-y', ['top', 'bottom']],
],
[
['start', ['inset-inline-start']],
['end', ['inset-inline-end']],
['top', ['top']],
['right', ['right']],
['bottom', ['bottom']],
Expand Down Expand Up @@ -674,6 +677,8 @@ export let corePlugins = {
['my', ['margin-top', 'margin-bottom']],
],
[
['ms', ['margin-inline-start']],
['me', ['margin-inline-end']],
['mt', ['margin-top']],
['mr', ['margin-right']],
['mb', ['margin-bottom']],
Expand Down Expand Up @@ -1022,6 +1027,8 @@ export let corePlugins = {
['scroll-my', ['scroll-margin-top', 'scroll-margin-bottom']],
],
[
['scroll-ms', ['scroll-margin-inline-start']],
['scroll-me', ['scroll-margin-inline-end']],
['scroll-mt', ['scroll-margin-top']],
['scroll-mr', ['scroll-margin-right']],
['scroll-mb', ['scroll-margin-bottom']],
Expand All @@ -1038,6 +1045,8 @@ export let corePlugins = {
['scroll-py', ['scroll-padding-top', 'scroll-padding-bottom']],
],
[
['scroll-ps', ['scroll-padding-inline-start']],
['scroll-pe', ['scroll-padding-inline-end']],
['scroll-pt', ['scroll-padding-top']],
['scroll-pr', ['scroll-padding-right']],
['scroll-pb', ['scroll-padding-bottom']],
Expand Down Expand Up @@ -1211,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 @@ -1246,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 Expand Up @@ -1435,12 +1465,18 @@ export let corePlugins = {
borderRadius: createUtilityPlugin('borderRadius', [
['rounded', ['border-radius']],
[
['rounded-s', ['border-start-start-radius', 'border-end-start-radius']],
['rounded-e', ['border-start-end-radius', 'border-end-end-radius']],
['rounded-t', ['border-top-left-radius', 'border-top-right-radius']],
['rounded-r', ['border-top-right-radius', 'border-bottom-right-radius']],
['rounded-b', ['border-bottom-right-radius', 'border-bottom-left-radius']],
['rounded-l', ['border-top-left-radius', 'border-bottom-left-radius']],
],
[
['rounded-ss', ['border-start-start-radius']],
['rounded-se', ['border-start-end-radius']],
['rounded-ee', ['border-end-end-radius']],
['rounded-es', ['border-end-start-radius']],
['rounded-tl', ['border-top-left-radius']],
['rounded-tr', ['border-top-right-radius']],
['rounded-br', ['border-bottom-right-radius']],
Expand All @@ -1457,6 +1493,8 @@ export let corePlugins = {
['border-y', [['@defaults border-width', {}], 'border-top-width', 'border-bottom-width']],
],
[
['border-s', [['@defaults border-width', {}], 'border-inline-start-width']],
['border-e', [['@defaults border-width', {}], 'border-inline-end-width']],
['border-t', [['@defaults border-width', {}], 'border-top-width']],
['border-r', [['@defaults border-width', {}], 'border-right-width']],
['border-b', [['@defaults border-width', {}], 'border-bottom-width']],
Expand Down Expand Up @@ -1539,6 +1577,32 @@ export let corePlugins = {

matchUtilities(
{
'border-s': (value) => {
if (!corePlugins('borderOpacity')) {
return {
'border-inline-start-color': toColorValue(value),
}
}

return withAlphaVariable({
color: value,
property: 'border-inline-start-color',
variable: '--tw-border-opacity',
})
},
'border-e': (value) => {
if (!corePlugins('borderOpacity')) {
return {
'border-inline-end-color': toColorValue(value),
}
}

return withAlphaVariable({
color: value,
property: 'border-inline-end-color',
variable: '--tw-border-opacity',
})
},
'border-t': (value) => {
if (!corePlugins('borderOpacity')) {
return {
Expand Down Expand Up @@ -1775,6 +1839,8 @@ export let corePlugins = {
['py', ['padding-top', 'padding-bottom']],
],
[
['ps', ['padding-inline-start']],
['pe', ['padding-inline-end']],
['pt', ['padding-top']],
['pr', ['padding-right']],
['pb', ['padding-bottom']],
Expand Down

0 comments on commit 9e34619

Please sign in to comment.