Skip to content

Commit

Permalink
Merge pull request tailwindlabs#1111 from hacknug/fix/box-sizing
Browse files Browse the repository at this point in the history
Fix `box-sizing` for shadow-dom elements
  • Loading branch information
adamwathan authored Oct 29, 2019
2 parents 490ef58 + 01a660a commit 163ab05
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 99 deletions.
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

0 comments on commit 163ab05

Please sign in to comment.