Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix box-sizing for shadow-dom elements #1111

Merged
merged 2 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 27 additions & 33 deletions __tests__/fixtures/tailwind-output-important.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,6 @@ template {
* suitable for web applications.
*/

/**
* 1. Prevent padding and border from affecting element width
* https://goo.gl/pYtbK7
* 2. Change the default font family in all browsers (opinionated)
*/

html {
box-sizing: border-box; /* 1 */
font-family: sans-serif; /* 2 */
}

*,
*::before,
*::after {
box-sizing: inherit;
}

/**
* Removes the default spacing and border for appropriate elements.
*/
Expand Down Expand Up @@ -425,7 +408,7 @@ ul {
/**
* 1. Use the system font stack as a sane default.
* 2. Use Tailwind's default "normal" line-height so the user isn't forced
* to override it to ensure consistency even when using the default theme.
* to override it to ensure consistency even when using the default theme.
*/

html {
Expand All @@ -434,27 +417,38 @@ html {
}

/**
* Allow adding a border to an element by just adding a border-width.
* 1. Prevent padding and border from affecting element width.
*
* We used to set this in the html element and inherit from
* the parent element for everything else. This caused issues
* in shadow-dom-enhanced elements like <details> where the content
* is wrapped by a div with box-sizing set to `content-box`.
*
* https://github.com/mozdevs/cssremedy/issues/4
*
* By default, the way the browser specifies that an element should have no
* border is by setting it's border-style to `none` in the user-agent
* stylesheet.
*
* In order to easily add borders to elements by just setting the `border-width`
* property, we change the default border-style for all elements to `solid`, and
* use border-width to hide them instead. This way our `border` utilities only
* need to set the `border-width` property instead of the entire `border`
* shorthand, making our border utilities much more straightforward to compose.
* 2. Allow adding a border to an element by just adding a border-width.
*
* https://github.com/tailwindcss/tailwindcss/pull/116
* By default, the way the browser specifies that an element should have no
* border is by setting it's border-style to `none` in the user-agent
* stylesheet.
*
* In order to easily add borders to elements by just setting the `border-width`
* property, we change the default border-style for all elements to `solid`, and
* use border-width to hide them instead. This way our `border` utilities only
* need to set the `border-width` property instead of the entire `border`
* shorthand, making our border utilities much more straightforward to compose.
*
* https://github.com/tailwindcss/tailwindcss/pull/116
*/

*,
*::before,
*::after {
border-width: 0;
border-style: solid;
border-color: #e2e8f0;
::before,
::after {
box-sizing: border-box; /* 1 */
border-width: 0; /* 2 */
border-style: solid; /* 2 */
border-color: #e2e8f0; /* 2 */
}

/*
Expand Down
60 changes: 27 additions & 33 deletions __tests__/fixtures/tailwind-output.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,23 +354,6 @@ template {
* suitable for web applications.
*/

/**
* 1. Prevent padding and border from affecting element width
* https://goo.gl/pYtbK7
* 2. Change the default font family in all browsers (opinionated)
*/

html {
box-sizing: border-box; /* 1 */
font-family: sans-serif; /* 2 */
}

*,
*::before,
*::after {
box-sizing: inherit;
}

/**
* Removes the default spacing and border for appropriate elements.
*/
Expand Down Expand Up @@ -425,7 +408,7 @@ ul {
/**
* 1. Use the system font stack as a sane default.
* 2. Use Tailwind's default "normal" line-height so the user isn't forced
* to override it to ensure consistency even when using the default theme.
* to override it to ensure consistency even when using the default theme.
*/

html {
Expand All @@ -434,27 +417,38 @@ html {
}

/**
* Allow adding a border to an element by just adding a border-width.
* 1. Prevent padding and border from affecting element width.
*
* We used to set this in the html element and inherit from
* the parent element for everything else. This caused issues
* in shadow-dom-enhanced elements like <details> where the content
* is wrapped by a div with box-sizing set to `content-box`.
*
* https://github.com/mozdevs/cssremedy/issues/4
*
*
* 2. Allow adding a border to an element by just adding a border-width.
*
* By default, the way the browser specifies that an element should have no
* border is by setting it's border-style to `none` in the user-agent
* stylesheet.
* By default, the way the browser specifies that an element should have no
* border is by setting it's border-style to `none` in the user-agent
* stylesheet.
*
* In order to easily add borders to elements by just setting the `border-width`
* property, we change the default border-style for all elements to `solid`, and
* use border-width to hide them instead. This way our `border` utilities only
* need to set the `border-width` property instead of the entire `border`
* shorthand, making our border utilities much more straightforward to compose.
* In order to easily add borders to elements by just setting the `border-width`
* property, we change the default border-style for all elements to `solid`, and
* use border-width to hide them instead. This way our `border` utilities only
* need to set the `border-width` property instead of the entire `border`
* shorthand, making our border utilities much more straightforward to compose.
*
* https://github.com/tailwindcss/tailwindcss/pull/116
* https://github.com/tailwindcss/tailwindcss/pull/116
*/

*,
*::before,
*::after {
border-width: 0;
border-style: solid;
border-color: #e2e8f0;
::before,
::after {
box-sizing: border-box; /* 1 */
border-width: 0; /* 2 */
border-style: solid; /* 2 */
border-color: #e2e8f0; /* 2 */
}

/*
Expand Down
63 changes: 30 additions & 33 deletions src/plugins/css/preflight.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@
* suitable for web applications.
*/

/**
* 1. Prevent padding and border from affecting element width
* https://goo.gl/pYtbK7
* 2. Change the default font family in all browsers (opinionated)
*/

html {
box-sizing: border-box; /* 1 */
font-family: sans-serif; /* 2 */
}

*,
*::before,
*::after {
box-sizing: inherit;
}

/**
* Removes the default spacing and border for appropriate elements.
*/
Expand Down Expand Up @@ -75,7 +58,7 @@ ul {
/**
* 1. Use the system font stack as a sane default.
* 2. Use Tailwind's default "normal" line-height so the user isn't forced
* to override it to ensure consistency even when using the default theme.
* to override it to ensure consistency even when using the default theme.
*/

html {
Expand All @@ -84,31 +67,44 @@ html {
}

/**
* Allow adding a border to an element by just adding a border-width.
* 1. Prevent padding and border from affecting element width.
*
* By default, the way the browser specifies that an element should have no
* border is by setting it's border-style to `none` in the user-agent
* stylesheet.
* We used to set this in the html element and inherit from
* the parent element for everything else. This caused issues
* in shadow-dom-enhanced elements like <details> where the content
* is wrapped by a div with box-sizing set to `content-box`.
*
* In order to easily add borders to elements by just setting the `border-width`
* property, we change the default border-style for all elements to `solid`, and
* use border-width to hide them instead. This way our `border` utilities only
* need to set the `border-width` property instead of the entire `border`
* shorthand, making our border utilities much more straightforward to compose.
* https://github.com/mozdevs/cssremedy/issues/4
*
* https://github.com/tailwindcss/tailwindcss/pull/116
*
* 2. Allow adding a border to an element by just adding a border-width.
*
* By default, the way the browser specifies that an element should have no
* border is by setting it's border-style to `none` in the user-agent
* stylesheet.
*
* In order to easily add borders to elements by just setting the `border-width`
* property, we change the default border-style for all elements to `solid`, and
* use border-width to hide them instead. This way our `border` utilities only
* need to set the `border-width` property instead of the entire `border`
* shorthand, making our border utilities much more straightforward to compose.
*
* https://github.com/tailwindcss/tailwindcss/pull/116
*/

*,
*::before,
*::after {
border-width: 0;
border-style: solid;
border-color: theme('borderColor.default', currentColor);
::before,
::after {
box-sizing: border-box; /* 1 */
border-width: 0; /* 2 */
border-style: solid; /* 2 */
border-color: theme('borderColor.default', currentColor); /* 2 */
}

/*
* Ensure horizontal rules are visible by default
*/

hr {
border-top-width: 1px;
}
Expand All @@ -122,6 +118,7 @@ hr {
*
* https://github.com/tailwindcss/tailwindcss/issues/362
*/

img {
border-style: solid;
}
Expand Down