Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
fix: Consistently define mixins as objects
Browse files Browse the repository at this point in the history
This prevents interpolation errors caused by spreading the output of a
styled-components `css` function into a CSS object
  • Loading branch information
diondiondion committed Aug 14, 2019
1 parent c0867c8 commit 4ce9be0
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 98 deletions.
9 changes: 0 additions & 9 deletions src/mixins/border.js

This file was deleted.

7 changes: 7 additions & 0 deletions src/mixins/borderValue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {alpha} from '../utils/colors';

function borderValue(theme) {
return `1px solid ${alpha(theme.shade, theme.lineStrength)}`;
}

export default borderValue;
12 changes: 5 additions & 7 deletions src/mixins/centerChildren.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {css} from 'styled-components';

const centerChildren = css`
display: flex;
align-items: center;
justify-content: center;
`;
const centerChildren = {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
};

export default centerChildren;
16 changes: 7 additions & 9 deletions src/mixins/fillParent.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {css} from 'styled-components';

const fillParent = css`
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
`;
const fillParent = {
position: 'absolute',
top: 0,
right: 0,
bottom: 0,
left: 0,
};

export default fillParent;
6 changes: 2 additions & 4 deletions src/mixins/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import border from './border';
import borderValue from './borderValue';
import centerChildren from './centerChildren';
import ellipsis from './ellipsis';
import fillParent from './fillParent';
import ie11Hack from './ie11Hack';
import overflowWrap from './overflowWrap';
import visuallyHidden from './visuallyHidden';
import zIndex from './zIndex';

export {
border,
borderValue,
centerChildren,
ellipsis,
fillParent,
ie11Hack,
overflowWrap,
visuallyHidden,
zIndex,
};
12 changes: 5 additions & 7 deletions src/mixins/overflowWrap.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {css} from 'styled-components';
const overflowWrap = {
overflowWrap: 'break-word',
wordWrap: 'break-word',

const overflowWrap = css`
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-word;
`;
wordBreak: 'break-word',
};

export default overflowWrap;
20 changes: 9 additions & 11 deletions src/mixins/visuallyHidden.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {css} from 'styled-components';

const visuallyHidden = css`
position: absolute;
overflow: hidden;
width: 1px;
height: 1px;
padding: 0;
clip: rect(0 0 0 0);
border: 0;
`;
const visuallyHidden = {
position: 'absolute',
overflow: 'hidden',
width: 1,
height: 1,
padding: 0,
clip: 'rect(0 0 0 0)',
border: 0,
};

export default visuallyHidden;
7 changes: 0 additions & 7 deletions src/mixins/zIndex.js

This file was deleted.

8 changes: 3 additions & 5 deletions src/styleProps/borderProps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {alpha} from '../utils/colors';
import {checkTheme} from '../utils/theme';

import {borderValue} from '../mixins';

const borderKeys = {
top: 'borderTop',
left: 'borderLeft',
Expand All @@ -18,10 +19,7 @@ function borderProps(props) {
}

return {
[borderKeys[border]]: `1px solid ${alpha(
theme.shade,
theme.lineStrength
)}`,
[borderKeys[border]]: borderValue(theme),
};
}

Expand Down
46 changes: 7 additions & 39 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3902,7 +3902,7 @@ debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
dependencies:
ms "^2.1.1"

debuglog@*, debuglog@^1.0.1:
debuglog@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
Expand Down Expand Up @@ -6417,7 +6417,7 @@ import-local@^2.0.0:
pkg-dir "^3.0.0"
resolve-cwd "^2.0.0"

imurmurhash@*, imurmurhash@^0.1.4:
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
Expand Down Expand Up @@ -7784,7 +7784,7 @@ libnpm@^2.0.1:
read-package-json "^2.0.13"
stringify-package "^1.0.0"

libnpmaccess@*, libnpmaccess@^3.0.1:
libnpmaccess@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/libnpmaccess/-/libnpmaccess-3.0.1.tgz#5b3a9de621f293d425191aa2e779102f84167fa8"
integrity sha512-RlZ7PNarCBt+XbnP7R6PoVgOq9t+kou5rvhaInoNibhPO7eMlRfS0B8yjatgn2yaHIwWNyoJDolC/6Lc5L/IQA==
Expand Down Expand Up @@ -7813,7 +7813,7 @@ libnpmhook@^5.0.2:
get-stream "^4.0.0"
npm-registry-fetch "^3.8.0"

libnpmorg@*, libnpmorg@^1.0.0:
libnpmorg@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/libnpmorg/-/libnpmorg-1.0.0.tgz#979b868c48ba28c5820e3bb9d9e73c883c16a232"
integrity sha512-o+4eVJBoDGMgRwh2lJY0a8pRV2c/tQM/SxlqXezjcAg26Qe9jigYVs+Xk0vvlYDWCDhP0g74J8UwWeAgsB7gGw==
Expand All @@ -7838,7 +7838,7 @@ libnpmpublish@^1.1.0:
semver "^5.5.1"
ssri "^6.0.1"

libnpmsearch@*, libnpmsearch@^2.0.0:
libnpmsearch@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/libnpmsearch/-/libnpmsearch-2.0.1.tgz#eccc73a8fbf267d765d18082b85daa2512501f96"
integrity sha512-K0yXyut9MHHCAH+DOiglQCpmBKPZXSUu76+BE2maSEfQN15OwNaA/Aiioe9lRFlVFOr7WcuJCY+VSl+gLi9NTA==
Expand All @@ -7847,7 +7847,7 @@ libnpmsearch@*, libnpmsearch@^2.0.0:
get-stream "^4.0.0"
npm-registry-fetch "^3.8.0"

libnpmteam@*, libnpmteam@^1.0.1:
libnpmteam@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/libnpmteam/-/libnpmteam-1.0.1.tgz#ff704b1b6c06ea674b3b1101ac3e305f5114f213"
integrity sha512-gDdrflKFCX7TNwOMX1snWojCoDE5LoRWcfOC0C/fqF7mBq8Uz9zWAX4B2RllYETNO7pBupBaSyBDkTAC15cAMg==
Expand Down Expand Up @@ -7965,11 +7965,6 @@ lockfile@^1.0.4:
dependencies:
signal-exit "^3.0.2"

lodash._baseindexof@*:
version "3.1.0"
resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c"
integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=

lodash._baseuniq@~4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8"
Expand All @@ -7978,33 +7973,11 @@ lodash._baseuniq@~4.6.0:
lodash._createset "~4.0.0"
lodash._root "~3.0.0"

lodash._bindcallback@*:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"
integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4=

lodash._cacheindexof@*:
version "3.0.2"
resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92"
integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=

lodash._createcache@*:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093"
integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=
dependencies:
lodash._getnative "^3.0.0"

lodash._createset@~4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26"
integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY=

lodash._getnative@*, lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=

lodash._root@~3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692"
Expand Down Expand Up @@ -8055,11 +8028,6 @@ lodash.iteratee@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.iteratee/-/lodash.iteratee-4.7.0.tgz#be4177db289a8ccc3c0990f1db26b5b22fc1554c"
integrity sha1-vkF32yiajMw8CZDx2ya1si/BVUw=

lodash.restparam@*:
version "3.6.1"
resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805"
integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=

lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
Expand Down Expand Up @@ -9098,7 +9066,7 @@ npm-pick-manifest@^2.2.3:
npm-package-arg "^6.0.0"
semver "^5.4.1"

npm-profile@*, npm-profile@^4.0.1:
npm-profile@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/npm-profile/-/npm-profile-4.0.1.tgz#d350f7a5e6b60691c7168fbb8392c3603583f5aa"
integrity sha512-NQ1I/1Q7YRtHZXkcuU1/IyHeLy6pd+ScKg4+DQHdfsm769TGq6HPrkbuNJVJS4zwE+0mvvmeULzQdWn2L2EsVA==
Expand Down

0 comments on commit 4ce9be0

Please sign in to comment.