Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use CSSTOM in default unit plugin (#893)
* Added support for using CSSTOM in default unit plugin * Support grid properties in default unit * - Move hasCSSTOMSupport into core - Improve default unit selection * - Move hasCSSTOMSupport into core - Improve default unit selection * Update size-snapshots
- Loading branch information
Henri
committed
Oct 17, 2018
1 parent
82dbfff
commit 2c87a93
Showing
12 changed files
with
211 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
interface CSSOM { | ||
px(val: number | string): {}; | ||
percent(val: number | string): {}; | ||
ms(val: number | string): {}; | ||
number(val: number | string): {}; | ||
} | ||
|
||
declare var CSS: ?CSSOM |
30 changes: 15 additions & 15 deletions
30
packages/jss-plugin-syntax-default-unit/.size-snapshot.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
240 changes: 136 additions & 104 deletions
240
packages/jss-plugin-syntax-default-unit/src/defaultUnits.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,146 @@ | ||
// @flow | ||
|
||
import {hasCSSTOMSupport} from 'jss' | ||
|
||
const px = hasCSSTOMSupport ? window.CSS.px : 'px' | ||
const ms = hasCSSTOMSupport ? window.CSS.ms : 'ms' | ||
const percent = hasCSSTOMSupport ? window.CSS.percent : '%' | ||
|
||
/** | ||
* Generated jss-plugin-syntax-default-unit CSS property units | ||
* | ||
* @type object | ||
*/ | ||
export default { | ||
'animation-delay': 'ms', | ||
'animation-duration': 'ms', | ||
'background-position': 'px', | ||
'background-position-x': 'px', | ||
'background-position-y': 'px', | ||
'background-size': 'px', | ||
border: 'px', | ||
'border-bottom': 'px', | ||
'border-bottom-left-radius': 'px', | ||
'border-bottom-right-radius': 'px', | ||
'border-bottom-width': 'px', | ||
'border-left': 'px', | ||
'border-left-width': 'px', | ||
'border-radius': 'px', | ||
'border-right': 'px', | ||
'border-right-width': 'px', | ||
'border-spacing': 'px', | ||
'border-top': 'px', | ||
'border-top-left-radius': 'px', | ||
'border-top-right-radius': 'px', | ||
'border-top-width': 'px', | ||
'border-width': 'px', | ||
'border-after-width': 'px', | ||
'border-before-width': 'px', | ||
'border-end-width': 'px', | ||
'border-horizontal-spacing': 'px', | ||
'border-start-width': 'px', | ||
'border-vertical-spacing': 'px', | ||
bottom: 'px', | ||
'box-shadow': 'px', | ||
'text-shadow': 'px', | ||
'column-gap': 'px', | ||
'column-rule': 'px', | ||
'column-rule-width': 'px', | ||
'column-width': 'px', | ||
'flex-basis': 'px', | ||
'font-size': 'px', | ||
'font-size-delta': 'px', | ||
height: 'px', | ||
left: 'px', | ||
'letter-spacing': 'px', | ||
'logical-height': 'px', | ||
'logical-width': 'px', | ||
margin: 'px', | ||
'margin-after': 'px', | ||
'margin-before': 'px', | ||
'margin-bottom': 'px', | ||
'margin-left': 'px', | ||
'margin-right': 'px', | ||
'margin-top': 'px', | ||
'max-height': 'px', | ||
'max-width': 'px', | ||
'margin-end': 'px', | ||
'margin-start': 'px', | ||
'mask-position-x': 'px', | ||
'mask-position-y': 'px', | ||
'mask-size': 'px', | ||
'max-logical-height': 'px', | ||
'max-logical-width': 'px', | ||
'min-height': 'px', | ||
'min-width': 'px', | ||
'min-logical-height': 'px', | ||
'min-logical-width': 'px', | ||
motion: 'px', | ||
'motion-offset': 'px', | ||
outline: 'px', | ||
'outline-offset': 'px', | ||
'outline-width': 'px', | ||
padding: 'px', | ||
'padding-bottom': 'px', | ||
'padding-left': 'px', | ||
'padding-right': 'px', | ||
'padding-top': 'px', | ||
'padding-after': 'px', | ||
'padding-before': 'px', | ||
'padding-end': 'px', | ||
'padding-start': 'px', | ||
'perspective-origin-x': '%', | ||
'perspective-origin-y': '%', | ||
perspective: 'px', | ||
right: 'px', | ||
'shape-margin': 'px', | ||
size: 'px', | ||
'text-indent': 'px', | ||
'text-stroke': 'px', | ||
'text-stroke-width': 'px', | ||
top: 'px', | ||
'transform-origin': '%', | ||
'transform-origin-x': '%', | ||
'transform-origin-y': '%', | ||
'transform-origin-z': '%', | ||
'transition-delay': 'ms', | ||
'transition-duration': 'ms', | ||
'vertical-align': 'px', | ||
width: 'px', | ||
'word-spacing': 'px', | ||
// Animation properties | ||
'animation-delay': ms, | ||
'animation-duration': ms, | ||
|
||
// Background properties | ||
'background-position': px, | ||
'background-position-x': px, | ||
'background-position-y': px, | ||
'background-size': px, | ||
|
||
// Border Properties | ||
border: px, | ||
'border-bottom': px, | ||
'border-bottom-left-radius': px, | ||
'border-bottom-right-radius': px, | ||
'border-bottom-width': px, | ||
'border-left': px, | ||
'border-left-width': px, | ||
'border-radius': px, | ||
'border-right': px, | ||
'border-right-width': px, | ||
'border-top': px, | ||
'border-top-left-radius': px, | ||
'border-top-right-radius': px, | ||
'border-top-width': px, | ||
'border-width': px, | ||
|
||
// Margin properties | ||
margin: px, | ||
'margin-bottom': px, | ||
'margin-left': px, | ||
'margin-right': px, | ||
'margin-top': px, | ||
|
||
// Padding properties | ||
padding: px, | ||
'padding-bottom': px, | ||
'padding-left': px, | ||
'padding-right': px, | ||
'padding-top': px, | ||
|
||
// Mask properties | ||
'mask-position-x': px, | ||
'mask-position-y': px, | ||
'mask-size': px, | ||
|
||
// Width and height properties | ||
height: px, | ||
width: px, | ||
'min-height': px, | ||
'max-height': px, | ||
'min-width': px, | ||
'max-width': px, | ||
|
||
// Position properties | ||
bottom: px, | ||
left: px, | ||
top: px, | ||
right: px, | ||
|
||
// Shadow properties | ||
'box-shadow': px, | ||
'text-shadow': px, | ||
|
||
// Column properties | ||
'column-gap': px, | ||
'column-rule': px, | ||
'column-rule-width': px, | ||
'column-width': px, | ||
|
||
// Font and text properties | ||
'font-size': px, | ||
'font-size-delta': px, | ||
'letter-spacing': px, | ||
'text-indent': px, | ||
'text-stroke': px, | ||
'text-stroke-width': px, | ||
'word-spacing': px, | ||
|
||
// Motion properties | ||
motion: px, | ||
'motion-offset': px, | ||
|
||
// Outline properties | ||
outline: px, | ||
'outline-offset': px, | ||
'outline-width': px, | ||
|
||
// Perspective properties | ||
perspective: px, | ||
'perspective-origin-x': percent, | ||
'perspective-origin-y': percent, | ||
|
||
// Transform properties | ||
'transform-origin': percent, | ||
'transform-origin-x': percent, | ||
'transform-origin-y': percent, | ||
'transform-origin-z': percent, | ||
|
||
// Transition properties | ||
'transition-delay': ms, | ||
'transition-duration': ms, | ||
|
||
// Alignment properties | ||
'vertical-align': px, | ||
'flex-basis': px, | ||
|
||
// Some random properties | ||
'shape-margin': px, | ||
size: px, | ||
|
||
// Grid properties | ||
grid: px, | ||
'grid-gap': px, | ||
'grid-row-gap': px, | ||
'grid-column-gap': px, | ||
'grid-template-rows': px, | ||
'grid-template-columns': px, | ||
'grid-auto-rows': px, | ||
'grid-auto-columns': px, | ||
|
||
// Not existing properties. | ||
// Used to avoid issues with jss-expand integration. | ||
'box-shadow-x': 'px', | ||
'box-shadow-y': 'px', | ||
'box-shadow-blur': 'px', | ||
'box-shadow-spread': 'px', | ||
'font-line-height': 'px', | ||
'text-shadow-x': 'px', | ||
'text-shadow-y': 'px', | ||
'text-shadow-blur': 'px' | ||
'box-shadow-x': px, | ||
'box-shadow-y': px, | ||
'box-shadow-blur': px, | ||
'box-shadow-spread': px, | ||
'font-line-height': px, | ||
'text-shadow-x': px, | ||
'text-shadow-y': px, | ||
'text-shadow-blur': px | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.