Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Oct 19, 2020
1 parent 6f003af commit cae420e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
"import/prefer-default-export": "off",
"no-underscore-dangle": "off",
"no-shadow": "off",
"guard-for-in": "off",
"react/no-danger": "off",
"operator-assignment": "off",
"prefer-destructuring": "off",
"react/state-in-constructor": "off",
"no-restricted-syntax": "off",
"no-continue": "off",
"react/destructuring-assignment": "off",
"@typescript-eslint/dot-notation": "off",
Expand Down
2 changes: 1 addition & 1 deletion packages/portal/tests/__snapshots__/portal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ exports[`should render nested portal 1`] = `
</DocumentFragment>
`;

exports[`should render portal 1`] = `"<div id=\\"chakra-toast-portal\\"><span id=\\"chakra-toast-manager-top\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; margin: 0px auto; text-align: center; top: 0px; right: 0px; left: 0px;\\"></span><span id=\\"chakra-toast-manager-top-left\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; top: 0px; left: 0px;\\"></span><span id=\\"chakra-toast-manager-top-right\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; top: 0px; right: 0px;\\"></span><span id=\\"chakra-toast-manager-bottom-left\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; bottom: 0px; left: 0px;\\"></span><span id=\\"chakra-toast-manager-bottom\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; margin: 0px auto; text-align: center; bottom: 0px; right: 0px; left: 0px;\\"></span><span id=\\"chakra-toast-manager-bottom-right\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; bottom: 0px; right: 0px;\\"></span></div><div><div class=\\"chakra-portal-manager\\"><div class=\\"chakra-portal\\">This is a portal</div></div></div>"`;
exports[`should render portal 1`] = `"<div id=\\"chakra-toast-portal\\"><ul id=\\"chakra-toast-manager-top\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; margin: 0px auto; top: 0px; right: 0px; left: 0px;\\"></ul><ul id=\\"chakra-toast-manager-top-left\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; top: 0px; left: 0px;\\"></ul><ul id=\\"chakra-toast-manager-top-right\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; top: 0px; right: 0px;\\"></ul><ul id=\\"chakra-toast-manager-bottom-left\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; bottom: 0px; left: 0px;\\"></ul><ul id=\\"chakra-toast-manager-bottom\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; margin: 0px auto; bottom: 0px; right: 0px; left: 0px;\\"></ul><ul id=\\"chakra-toast-manager-bottom-right\\" style=\\"position: fixed; z-index: 5500; pointer-events: none; display: flex; flex-direction: column; bottom: 0px; right: 0px;\\"></ul></div><div><div class=\\"chakra-portal-manager\\"><div class=\\"chakra-portal\\">This is a portal</div></div></div>"`;
24 changes: 12 additions & 12 deletions packages/styled-system/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ const responsive = (styles: any) => (theme: Dict) => {
theme.breakpoints,
)

Object.keys(styles).forEach((key) => {
for (const key in styles) {
let value = runIfFn(styles[key], theme)

if (value == null) {
return
continue
}

value = isResponsiveObjectLike(value, breakpoints)
Expand All @@ -104,7 +104,7 @@ const responsive = (styles: any) => (theme: Dict) => {

if (!isArray(value)) {
computedStyles[key] = value
return
continue
}

const queries = value.slice(0, mediaQueries.length).length
Expand All @@ -125,7 +125,7 @@ const responsive = (styles: any) => (theme: Dict) => {

computedStyles[media][key] = value[index]
}
})
}

return computedStyles
}
Expand All @@ -142,7 +142,7 @@ export const css = (args: StyleObjectOrFn = {}) => (
const styleObject = runIfFn(args, theme)
const styles = responsive(styleObject)(theme)

Object.keys(styles).forEach((k) => {
for (const k in styles) {
const x = styles[k]
const val = runIfFn(x, theme)

Expand All @@ -152,31 +152,31 @@ export const css = (args: StyleObjectOrFn = {}) => (
if (key === "apply") {
const apply = css(get(theme, val))(theme)
computedStyles = mergeWith({}, computedStyles, apply)
return
continue
}

if (isObject(val)) {
computedStyles[key] = css(val)(theme)
return
continue
}

const scale = get(theme, config?.scale, {})
const value = config?.transform?.(val, scale) ?? get(scale, val, val)

if (config?.properties) {
config.properties.forEach((property: string) => {
for (const property of config.properties) {
computedStyles[property] = value
})
return
}
continue
}

if (config?.property) {
computedStyles[config.property] = value
return
continue
}

computedStyles[key] = value
})
}

return computedStyles
}
2 changes: 1 addition & 1 deletion packages/system/tests/style-resolver.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { styleResolver } from "../src/system"
import theme from "@chakra-ui/theme"
import { styleResolver } from "../src/system"

const customTheme: any = {
...theme,
Expand Down

0 comments on commit cae420e

Please sign in to comment.