├── .nvmrc ├── examples ├── with-jsx │ ├── .gitignore │ ├── index.html │ └── main.js └── with-next │ ├── .gitignore │ ├── .babelrc │ ├── package.json │ └── pages │ ├── about.js │ ├── index.js │ └── _app.js ├── packages ├── benefit-docs │ ├── src │ │ ├── components │ │ │ ├── Sandbox.js │ │ │ ├── Logo.js │ │ │ ├── Tablet.js │ │ │ ├── Icon.js │ │ │ ├── Phone.js │ │ │ ├── Grid.js │ │ │ ├── BrowserBox.js │ │ │ ├── header.js │ │ │ ├── InfoBox.js │ │ │ ├── image.js │ │ │ ├── UtilityBox.js │ │ │ └── Color.js │ │ ├── images │ │ │ ├── gatsby-icon.png │ │ │ └── gatsby-astronaut.png │ │ ├── docs │ │ │ ├── whats-included.mdx │ │ │ ├── helpers │ │ │ │ ├── css.mdx │ │ │ │ ├── global.mdx │ │ │ │ └── keyframes.mdx │ │ │ ├── installation.mdx │ │ │ ├── utilities │ │ │ │ ├── interactivity │ │ │ │ │ ├── cursor.mdx │ │ │ │ │ ├── user-select.mdx │ │ │ │ │ ├── resize.mdx │ │ │ │ │ ├── pointer-events.mdx │ │ │ │ │ └── outline.mdx │ │ │ │ ├── border │ │ │ │ │ ├── border-color.mdx │ │ │ │ │ ├── border-style.mdx │ │ │ │ │ └── border-width.mdx │ │ │ │ ├── background │ │ │ │ │ ├── background-color.mdx │ │ │ │ │ └── background-size.mdx │ │ │ │ ├── typography │ │ │ │ │ ├── font-size.mdx │ │ │ │ │ ├── font-weight.mdx │ │ │ │ │ ├── font-family.mdx │ │ │ │ │ ├── text-color.mdx │ │ │ │ │ ├── letter-spacing.mdx │ │ │ │ │ ├── line-height.mdx │ │ │ │ │ └── text-alignment.mdx │ │ │ │ ├── layout │ │ │ │ │ ├── visibility.mdx │ │ │ │ │ └── container.mdx │ │ │ │ ├── effects │ │ │ │ │ ├── opacity.mdx │ │ │ │ │ └── box-shadow.mdx │ │ │ │ ├── svg │ │ │ │ │ ├── stroke.mdx │ │ │ │ │ └── fill.mdx │ │ │ │ └── flexbox │ │ │ │ │ ├── display.mdx │ │ │ │ │ ├── grow.mdx │ │ │ │ │ ├── shrink.mdx │ │ │ │ │ └── flex-wrapping.mdx │ │ │ ├── installation │ │ │ │ ├── agnostic.mdx │ │ │ │ └── react.mdx │ │ │ ├── customization │ │ │ │ ├── theme.mdx │ │ │ │ ├── normalize.mdx │ │ │ │ └── apply.mdx │ │ │ └── introduction.mdx │ │ ├── svg │ │ │ ├── droplet.svg │ │ │ ├── square.svg │ │ │ ├── mouse-pointer.svg │ │ │ ├── maximize.svg │ │ │ ├── type.svg │ │ │ ├── image.svg │ │ │ ├── layout.svg │ │ │ ├── pen-tool.svg │ │ │ ├── grid.svg │ │ │ ├── move.svg │ │ │ ├── github.svg │ │ │ ├── loader.svg │ │ │ └── flex.svg │ │ └── pages │ │ │ └── 404.js │ ├── .prettierrc │ ├── gatsby-ssr.js │ ├── LICENSE │ ├── .gitignore │ ├── gatsby-node.js │ ├── gatsby-config.js │ └── package.json ├── benefit-docs-old │ ├── utilities │ │ ├── size │ │ │ ├── max-height.mdx │ │ │ ├── max-width.mdx │ │ │ ├── min-height.mdx │ │ │ └── min-width.mdx │ │ ├── interactivity │ │ │ ├── cursor.mdx │ │ │ ├── user-select.mdx │ │ │ ├── resize.mdx │ │ │ └── pointer-events.mdx │ │ ├── layout │ │ │ ├── visibility.mdx │ │ │ └── container.mdx │ │ ├── background │ │ │ ├── background-color.mdx │ │ │ └── background-size.mdx │ │ ├── typography │ │ │ ├── font-family.mdx │ │ │ ├── text-color.mdx │ │ │ ├── font-size.mdx │ │ │ ├── font-weight.mdx │ │ │ ├── letter-spacing.mdx │ │ │ ├── line-height.mdx │ │ │ └── text-alignment.mdx │ │ ├── border │ │ │ ├── border-color.mdx │ │ │ └── border-style.mdx │ │ ├── effects │ │ │ ├── opacity.mdx │ │ │ └── box-shadow.mdx │ │ ├── svg │ │ │ ├── stroke.mdx │ │ │ └── fill.mdx │ │ └── flexbox │ │ │ ├── display.mdx │ │ │ ├── grow.mdx │ │ │ └── shrink.mdx │ ├── test.mdx │ ├── benefit-logo.png │ ├── benefit-logo-dark.png │ ├── images │ │ └── benefit-example.png │ ├── theme │ │ ├── components │ │ │ ├── Container.js │ │ │ ├── H1.js │ │ │ └── Loader.js │ │ ├── Menu.js │ │ └── index.html │ ├── svg │ │ ├── droplet.svg │ │ ├── square.svg │ │ ├── mouse-pointer.svg │ │ ├── maximize.svg │ │ ├── type.svg │ │ ├── image.svg │ │ ├── layout.svg │ │ ├── pen-tool.svg │ │ ├── grid.svg │ │ ├── move.svg │ │ ├── github.svg │ │ ├── loader.svg │ │ └── flex.svg │ ├── doczrc.js │ ├── components │ │ ├── Logo.js │ │ ├── Grid.js │ │ ├── Icons.js │ │ ├── Phone.js │ │ ├── Tablet.js │ │ ├── BrowserBox.js │ │ ├── InfoBox.js │ │ ├── UtilityBox.js │ │ └── Color.js │ ├── doczTheme.js │ ├── package.json │ ├── introduction.mdx │ ├── customization │ │ ├── theme.mdx │ │ ├── normalize.mdx │ │ ├── apply.mdx │ │ └── overview.mdx │ ├── utilities.mdx │ └── color.mdx ├── benefit │ ├── config │ │ ├── utilities │ │ │ ├── outline.ts │ │ │ ├── appearance.ts │ │ │ ├── visibility.ts │ │ │ ├── tableLayout.ts │ │ │ ├── pointerEvents.ts │ │ │ ├── listStylePosition.ts │ │ │ ├── fontStyle.ts │ │ │ ├── flexWrap.ts │ │ │ ├── resize.ts │ │ │ ├── textDecoration.ts │ │ │ ├── textAlign.ts │ │ │ ├── userSelect.ts │ │ │ ├── fill.ts │ │ │ ├── textTransform.ts │ │ │ ├── borderCollapse.ts │ │ │ ├── fontSize.ts │ │ │ ├── flexGrow.ts │ │ │ ├── zIndex.ts │ │ │ ├── stroke.ts │ │ │ ├── flexShrink.ts │ │ │ ├── objectFit.ts │ │ │ ├── opacity.ts │ │ │ ├── alignSelf.ts │ │ │ ├── boxShadow.ts │ │ │ ├── fontWeight.ts │ │ │ ├── flexDirection.ts │ │ │ ├── lineHeight.ts │ │ │ ├── backgroundSize.ts │ │ │ ├── fontFamily.ts │ │ │ ├── listStyleType.ts │ │ │ ├── verticalAlign.ts │ │ │ ├── alignItems.ts │ │ │ ├── letterSpacing.ts │ │ │ ├── objectPosition.ts │ │ │ ├── borderStyle.ts │ │ │ ├── fontSmoothing.ts │ │ │ ├── backgroundPosition.ts │ │ │ ├── whitespace.ts │ │ │ ├── alignContent.ts │ │ │ ├── backgroundAttachment.ts │ │ │ ├── justifyContent.ts │ │ │ ├── textColor.ts │ │ │ ├── borderColor.ts │ │ │ ├── backgroundColor.ts │ │ │ ├── cursor.ts │ │ │ ├── wordBreak.ts │ │ │ ├── float.ts │ │ │ ├── display.ts │ │ │ ├── container.ts │ │ │ ├── flex.ts │ │ │ ├── backgroundRepeat.ts │ │ │ ├── width.ts │ │ │ ├── height.ts │ │ │ ├── overflow.ts │ │ │ ├── borderWidth.ts │ │ │ ├── inset.ts │ │ │ ├── padding.ts │ │ │ └── position.ts │ │ ├── defaultConfig.ts │ │ ├── variants │ │ │ ├── index.ts │ │ │ ├── focus.ts │ │ │ ├── hover.ts │ │ │ ├── active.ts │ │ │ ├── focus-within.ts │ │ │ └── responsive.ts │ │ ├── createVariant.ts │ │ ├── normalize.ts │ │ ├── createVariantsFromMap.ts │ │ ├── createUtilitiesFromMap.ts │ │ └── flattenColorConfig.ts │ ├── util │ │ ├── isBrowser.ts │ │ ├── getProcessedRules.ts │ │ ├── createUtilityMap.ts │ │ ├── createVariantMap.ts │ │ ├── parseDeclarations.ts │ │ ├── createHash.ts │ │ ├── initializeContainers.ts │ │ ├── createCache.ts │ │ └── insertStyle.ts │ ├── README.md │ ├── tsconfig.json │ ├── index.ts │ ├── package.json │ └── LICENSE ├── benefit-react │ ├── Preflight.tsx │ ├── jsx.tsx │ ├── tsconfig.json │ ├── index.ts │ ├── LICENSE │ ├── package.json │ ├── README.md │ ├── Box.tsx │ └── ServerStyleManager.tsx └── examples │ └── with-next │ ├── package.json │ └── pages │ ├── about.js │ ├── _document.js │ └── _app.js ├── .gitattributes ├── jest.config.js ├── .vscode └── settings.json ├── netlify.toml ├── .prettierrc ├── __tests__ └── benefit.test.js ├── LICENSE ├── .gitignore ├── scripts └── css.js └── rollup.config.js /.nvmrc: -------------------------------------------------------------------------------- 1 | v10.16.3 -------------------------------------------------------------------------------- /examples/with-jsx/.gitignore: -------------------------------------------------------------------------------- 1 | .cache -------------------------------------------------------------------------------- /examples/with-next/.gitignore: -------------------------------------------------------------------------------- 1 | .next -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/Sandbox.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | yarn.lock linguist-generated=true 2 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/size/max-height.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/size/max-width.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/size/min-height.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/size/min-width.mdx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: "jest-puppeteer", 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib" 3 | } -------------------------------------------------------------------------------- /packages/benefit-docs-old/test.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Test 3 | route: /test 4 | --- 5 | 6 | Hi 7 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [[redirects]] 2 | from = "/*" 3 | to = "/index.html" 4 | status = 200 5 | force = false -------------------------------------------------------------------------------- /packages/benefit-docs-old/benefit-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdonohue/benefit/HEAD/packages/benefit-docs-old/benefit-logo.png -------------------------------------------------------------------------------- /packages/benefit/config/utilities/outline.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { "outline-none": { outline: 0 } } 3 | } 4 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/benefit-logo-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdonohue/benefit/HEAD/packages/benefit-docs-old/benefit-logo-dark.png -------------------------------------------------------------------------------- /packages/benefit-docs/src/images/gatsby-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdonohue/benefit/HEAD/packages/benefit-docs/src/images/gatsby-icon.png -------------------------------------------------------------------------------- /packages/benefit/config/utilities/appearance.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { "appearance-none": { appearance: "none" } } 3 | } 4 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/images/benefit-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdonohue/benefit/HEAD/packages/benefit-docs-old/images/benefit-example.png -------------------------------------------------------------------------------- /packages/benefit-docs/src/images/gatsby-astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdonohue/benefit/HEAD/packages/benefit-docs/src/images/gatsby-astronaut.png -------------------------------------------------------------------------------- /packages/benefit/util/isBrowser.ts: -------------------------------------------------------------------------------- 1 | export default function isBrowser() { 2 | return typeof window !== "undefined" && typeof document !== "undefined" 3 | } 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "semi": false, 4 | "trailingComma": "es5", 5 | "bracketSpacing": true, 6 | "jsxBracketSameLine": false 7 | } 8 | -------------------------------------------------------------------------------- /packages/benefit-docs/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "endOfLine": "lf", 3 | "semi": false, 4 | "singleQuote": false, 5 | "tabWidth": 2, 6 | "trailingComma": "es5" 7 | } 8 | -------------------------------------------------------------------------------- /packages/benefit-react/Preflight.tsx: -------------------------------------------------------------------------------- 1 | import { injectPreflight } from "benefit" 2 | 3 | export default function Preflight({ selector = "" }) { 4 | injectPreflight(selector) 5 | return null 6 | } 7 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/visibility.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | visible: { visibility: "visible" }, 4 | invisible: { visibility: "hidden" }, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/tableLayout.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "table-auto": { "table-layout": "auto" }, 4 | "table-fixed": { "table-layout": "fixed" }, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/with-next/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "next/babel", 5 | { 6 | "preset-react": { 7 | "pragma": "jsx" 8 | } 9 | } 10 | ] 11 | ], 12 | "plugins": [] 13 | } 14 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/whats-included.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: 3 | route: /whats-included 4 | previousRoute: /getting-started 5 | previousLabel: Getting Started 6 | nextRoute: /customization/overview 7 | nextLabel: Customization 8 | --- 9 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/pointerEvents.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "pointer-events-none": { "pointer-events": "none" }, 4 | "pointer-events-auto": { "pointer-events": "auto" }, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/listStylePosition.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "list-inside": { "list-style-position": "inside" }, 4 | "list-outside": { "list-style-position": "outside" }, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/helpers/css.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: CSS 3 | route: /helpers/css/ 4 | parent: Helpers 5 | previousRoute: /installation/react/ 6 | previousLabel: React 7 | nextRoute: /helpers/global/ 8 | nextLabel: Global 9 | --- 10 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/helpers/global.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Global 3 | route: /helpers/global/ 4 | parent: Helpers 5 | previousRoute: /helpers/css/ 6 | previousLabel: CSS 7 | nextRoute: /helpers/keyframes/ 8 | nextLabel: Keyframes 9 | --- 10 | -------------------------------------------------------------------------------- /packages/benefit/config/defaultConfig.ts: -------------------------------------------------------------------------------- 1 | import theme from "./theme" 2 | import utilities from "./utilities" 3 | import variants from "./variants" 4 | 5 | export default { 6 | prefix: "", 7 | 8 | theme, 9 | utilities, 10 | variants, 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/fontStyle.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | italic: { 4 | "font-style": "italic", 5 | }, 6 | "not-italic": { 7 | "font-style": "normal", 8 | }, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/flexWrap.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "flex-wrap": { "flex-wrap": "wrap" }, 4 | "flex-wrap-reverse": { "flex-wrap": "wrap-reverse" }, 5 | "flex-no-wrap": { "flex-wrap": "nowrap" }, 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/theme/components/Container.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function Container({ children, className }) { 5 | return {children} 6 | } 7 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/helpers/keyframes.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Keyframes 3 | route: /helpers/keyframes/ 4 | parent: Helpers 5 | previousRoute: /helpers/global/ 6 | previousLabel: Global 7 | nextRoute: /customization/overview/ 8 | nextLabel: Customization 9 | --- 10 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/resize.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "resize-none": { resize: "none" }, 4 | "resize-x": { resize: "horizontal" }, 5 | "resize-y": { resize: "vertical" }, 6 | resize: { resize: "both" }, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/textDecoration.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | underline: { "text-decoration": "underline" }, 4 | "line-through": { "text-decoration": "line-through" }, 5 | "no-underline": { "text-decoration": "none" }, 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/benefit/config/variants/index.ts: -------------------------------------------------------------------------------- 1 | import active from "./active" 2 | import focus from "./focus" 3 | import focusWithin from "./focus-within" 4 | import hover from "./hover" 5 | import responsive from "./responsive" 6 | 7 | export default [active, focus, focusWithin, hover, responsive] 8 | -------------------------------------------------------------------------------- /packages/benefit/config/variants/focus.ts: -------------------------------------------------------------------------------- 1 | import createVariant from "../createVariant" 2 | 3 | export default function generate(utilityMap: any) { 4 | return createVariant( 5 | utilityMap, 6 | (value: string) => ({ 7 | "&:focus": value, 8 | }), 9 | "focus" 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit/config/variants/hover.ts: -------------------------------------------------------------------------------- 1 | import createVariant from "../createVariant" 2 | 3 | export default function generate(utilityMap: any) { 4 | return createVariant( 5 | utilityMap, 6 | (value: string) => ({ 7 | "&:hover": value, 8 | }), 9 | "hover" 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/droplet.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/droplet.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/textAlign.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "text-left": { "text-align": "left" }, 4 | "text-right": { "text-align": "right" }, 5 | "text-center": { "text-align": "center" }, 6 | "text-justify": { "text-align": "justify" }, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/userSelect.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "select-all": { "user-select": "all" }, 4 | "select-auto": { "user-select": "auto" }, 5 | "select-none": { "user-select": "none" }, 6 | "select-text": { "user-select": "text" }, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/benefit/config/variants/active.ts: -------------------------------------------------------------------------------- 1 | import createVariant from "../createVariant" 2 | 3 | export default function generate(utilityMap: any) { 4 | return createVariant( 5 | utilityMap, 6 | (value: string) => ({ 7 | "&:active": value, 8 | }), 9 | "active" 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/square.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/theme/components/H1.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function H1(props) { 5 | return ( 6 | 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/square.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/variants/focus-within.ts: -------------------------------------------------------------------------------- 1 | import createVariant from "../createVariant" 2 | 3 | export default function generate(utilityMap: any) { 4 | return createVariant( 5 | utilityMap, 6 | (value: string) => ({ 7 | "&:focus-within": value, 8 | }), 9 | "focus-within" 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/fill.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { fill = {} } = theme 5 | return createUtilitiesFromMap( 6 | fill, 7 | (value: string) => ({ fill: value }), 8 | "fill" 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/textTransform.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | uppercase: { "text-transform": "uppercase" }, 4 | lowercase: { "text-transform": "lowercase" }, 5 | capitalize: { "text-transform": "capitalize" }, 6 | "normal-case": { "text-transform": "none" }, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/mouse-pointer.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/mouse-pointer.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/borderCollapse.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate() { 4 | return createUtilitiesFromMap( 5 | ["collapse", "separate"], 6 | (value: string) => ({ 7 | "border-collapse": value, 8 | }), 9 | "border" 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/fontSize.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { fontSize = {} } = theme 5 | return createUtilitiesFromMap( 6 | fontSize, 7 | (value: string) => ({ "font-size": value }), 8 | "text" 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/flexGrow.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { flexGrow = {} } = theme 5 | return createUtilitiesFromMap( 6 | flexGrow, 7 | (value: string) => ({ "flex-grow": value }), 8 | "flex-grow" 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/zIndex.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { zIndex } = theme 5 | return createUtilitiesFromMap( 6 | zIndex, 7 | (value: string) => ({ 8 | "z-index": value, 9 | }), 10 | "z" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/util/getProcessedRules.ts: -------------------------------------------------------------------------------- 1 | import stylis from "stylis" 2 | 3 | const processor = new stylis({ 4 | keyframe: false, 5 | }) 6 | 7 | export default function getProcessedRules( 8 | selector: string, 9 | cssRules: string 10 | ): string { 11 | return processor(selector.replace(":", "\\:").replace("/", "\\/"), cssRules) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/stroke.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { stroke = {} } = theme 5 | return createUtilitiesFromMap( 6 | stroke, 7 | (value: string) => ({ 8 | stroke: value, 9 | }), 10 | "stroke" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/maximize.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/maximize.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/flexShrink.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { flexShrink = {} } = theme 5 | return createUtilitiesFromMap( 6 | flexShrink, 7 | (value: string) => ({ "flex-shrink": value }), 8 | "flex-shrink" 9 | ) 10 | } 11 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/objectFit.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate() { 4 | return createUtilitiesFromMap( 5 | ["contain", "cover", "fill", "none", "scale-down"], 6 | (value: string) => ({ 7 | "object-fit": value, 8 | }), 9 | "object" 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/opacity.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { opacity = {} } = theme 5 | return createUtilitiesFromMap( 6 | opacity, 7 | (value: string) => ({ 8 | opacity: value, 9 | }), 10 | "opacity" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/pages/404.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | 3 | import SEO from "../components/seo" 4 | 5 | const NotFoundPage = () => ( 6 |
7 | 8 |

NOT FOUND

9 |

You just hit a route that doesn't exist... the sadness.

10 |
11 | ) 12 | 13 | export default NotFoundPage 14 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/alignSelf.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "self-auto": { "align-self": "auto" }, 4 | "self-start": { "align-self": "flex-start" }, 5 | "self-end": { "align-self": "flex-end" }, 6 | "self-center": { "align-self": "center" }, 7 | "self-stretch": { "align-self": "stretch" }, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/boxShadow.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { boxShadow = {} } = theme 5 | return createUtilitiesFromMap( 6 | boxShadow, 7 | (value: string) => ({ 8 | "box-shadow": value, 9 | }), 10 | "shadow" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/fontWeight.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { fontWeight = {} } = theme 5 | return createUtilitiesFromMap( 6 | fontWeight, 7 | (value: string) => ({ 8 | "font-weight": value, 9 | }), 10 | "font" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/flexDirection.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "flex-row": { "flex-direction": "row" }, 4 | "flex-row-reverse": { "flex-direction": "row-reverse" }, 5 | "flex-col": { "flex-direction": "column" }, 6 | "flex-col-reverse": { 7 | "flex-direction": "column-reverse", 8 | }, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/lineHeight.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { lineHeight = {} } = theme 5 | return createUtilitiesFromMap( 6 | lineHeight, 7 | (value: string) => ({ 8 | "line-height": value, 9 | }), 10 | "leading" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/type.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/type.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/backgroundSize.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { backgroundSize } = theme 5 | return createUtilitiesFromMap( 6 | backgroundSize, 7 | (value: string) => ({ 8 | "background-size": value, 9 | }), 10 | "bg" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit-react/jsx.tsx: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import Box from "./Box" 3 | 4 | export default function jsx(type: any, props: any, ...children: any[]) { 5 | if (props && (props.className || props.css)) { 6 | return React.createElement(Box, { ...props, is: type }, ...children) 7 | } 8 | 9 | return React.createElement(type, { ...props }, ...children) 10 | } 11 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/fontFamily.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { fontFamily = {} } = theme 5 | return createUtilitiesFromMap( 6 | fontFamily, 7 | (value: string[]) => ({ 8 | "font-family": value.join(","), 9 | }), 10 | "font" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/listStyleType.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { listStyleType = {} } = theme 5 | return createUtilitiesFromMap( 6 | listStyleType, 7 | (value: string) => ({ 8 | "list-style-type": value, 9 | }), 10 | "list" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/verticalAlign.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate() { 4 | return createUtilitiesFromMap( 5 | ["baseline", "top", "middle", "bottom", "text-top", "text-bottom"], 6 | (value: string) => ({ 7 | "vertical-align": value, 8 | }), 9 | "align" 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /examples/with-next/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-next", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "scripts": { 7 | "dev": "next dev" 8 | }, 9 | "dependencies": { 10 | "@emotion/core": "^10.0.10", 11 | "emotion": "^10.0.9", 12 | "next": "^8.1.0", 13 | "react": "^16.8.6", 14 | "react-dom": "^16.8.6" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/alignItems.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "items-start": { "align-items": "flex-start" }, 4 | "items-end": { "align-items": "flex-end" }, 5 | "items-center": { "align-items": "center" }, 6 | "items-baseline": { "align-items": "baseline" }, 7 | "items-stretch": { "align-items": "stretch" }, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/letterSpacing.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { letterSpacing = {} } = theme 5 | return createUtilitiesFromMap( 6 | letterSpacing, 7 | (value: string) => ({ 8 | "letter-spacing": value, 9 | }), 10 | "tracking" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/objectPosition.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { objectPosition = {} } = theme 5 | return createUtilitiesFromMap( 6 | objectPosition, 7 | (value: string) => ({ 8 | "object-position": value, 9 | }), 10 | "object" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/image.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/layout.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/image.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/layout.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/borderStyle.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | const borderStyles = ["solid", "dashed", "dotted", "none"] 4 | 5 | export default function generate() { 6 | return createUtilitiesFromMap( 7 | borderStyles, 8 | (value: string) => ({ 9 | "border-style": value, 10 | }), 11 | "border" 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/fontSmoothing.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | antialiased: { 4 | "-webkit-font-smoothing": "antialiased", 5 | "-moz-osx-font-smoothing": "antialiased", 6 | }, 7 | "subpixel-antialiased": { 8 | "-webkit-font-smoothing": "auto", 9 | "-moz-osx-font-smoothing": "auto", 10 | }, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/examples/with-next/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-next", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "scripts": { 7 | "dev": "next dev" 8 | }, 9 | "dependencies": { 10 | "benefit-react": "2.1.0", 11 | "next": "9.0.5", 12 | "polychrome": "^4.1.2", 13 | "react": "16.9.0", 14 | "react-dom": "16.9.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/backgroundPosition.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { backgroundPosition = {} } = theme 5 | return createUtilitiesFromMap( 6 | backgroundPosition, 7 | (value: string) => ({ 8 | "background-position": value, 9 | }), 10 | "bg" 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/whitespace.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "whitespace-normal": { "white-space": "normal" }, 4 | "whitespace-no-wrap": { "white-space": "nowrap" }, 5 | "whitespace-pre": { "white-space": "pre" }, 6 | "whitespace-pre-line": { "white-space": "pre-line" }, 7 | "whitespace-pre-wrap": { "white-space": "pre-wrap" }, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/doczrc.js: -------------------------------------------------------------------------------- 1 | export default { 2 | title: "benefit", 3 | description: "5kB utility CSS library that is compatible with TailwindCSS", 4 | theme: "theme/index", 5 | modifyBundlerConfig: (config) => { 6 | config.module.rules.push({ 7 | test: /\.tsx?$/, 8 | use: "ts-loader", 9 | exclude: /node_modules/, 10 | }) 11 | 12 | return config 13 | }, 14 | } 15 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/pen-tool.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/pen-tool.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/alignContent.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "content-start": { "align-content": "flex-start" }, 4 | "content-end": { "align-content": "flex-end" }, 5 | "content-center": { "align-content": "center" }, 6 | "content-between": { "align-content": "space-between" }, 7 | "content-around": { "align-content": "space-around" }, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/backgroundAttachment.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | const backgroundAttachment = ["fixed", "local", "scroll"] 4 | 5 | export default function generate() { 6 | return createUtilitiesFromMap( 7 | backgroundAttachment, 8 | (value: string) => ({ 9 | "background-attachment": value, 10 | }), 11 | "bg" 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /examples/with-jsx/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/grid.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/grid.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/justifyContent.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "justify-start": { "justify-content": "flex-start" }, 4 | "justify-end": { "justify-content": "flex-end" }, 5 | "justify-center": { "justify-content": "center" }, 6 | "justify-between": { "justify-content": "space-between" }, 7 | "justify-around": { "justify-content": "space-around" }, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/with-next/pages/about.js: -------------------------------------------------------------------------------- 1 | import { jsx } from "../../../dist/react" 2 | 3 | function About() { 4 | return ( 5 |
6 | Welcome to About{" "} 7 | 11 | Back Home 12 | {" "} 13 |
14 | ) 15 | } 16 | 17 | export default About 18 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/textColor.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | import flattenColorConfig from "../flattenColorConfig" 3 | 4 | export default function generate(theme: any) { 5 | const { textColor = {} } = theme 6 | return createUtilitiesFromMap( 7 | flattenColorConfig(textColor), 8 | (value: string) => ({ 9 | color: value, 10 | }), 11 | "text" 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /packages/benefit/config/createVariant.ts: -------------------------------------------------------------------------------- 1 | export default function createVariant( 2 | utilities: any, 3 | generateDeclarations: any, 4 | prefix: any 5 | ) { 6 | if (!utilities) { 7 | return {} 8 | } 9 | return Object.keys(utilities).reduce((variants: any, utilityKey) => { 10 | variants[`${prefix}:${utilityKey}`] = generateDeclarations( 11 | utilities[utilityKey] 12 | ) 13 | return variants 14 | }, {}) 15 | } 16 | -------------------------------------------------------------------------------- /packages/benefit/config/variants/responsive.ts: -------------------------------------------------------------------------------- 1 | import createVariantsFromMap from "../createVariantsFromMap" 2 | 3 | export default function generate(utilities: any, theme: any) { 4 | const { screens = {} } = theme 5 | 6 | return createVariantsFromMap( 7 | utilities, 8 | screens, 9 | (variantValue: string, declarations: string) => ({ 10 | [`@media(min-width: ${variantValue})`]: declarations, 11 | }) 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /__tests__/benefit.test.js: -------------------------------------------------------------------------------- 1 | const benefit = require("../dist/benefit")() 2 | 3 | describe("benefit()", () => { 4 | it("should match snapshot of exports", async () => { 5 | expect(Object.keys(benefit)).toMatchInlineSnapshot(` 6 | Array [ 7 | "config", 8 | "cssForUtility", 9 | "cx", 10 | "getDeclarationsForClasses", 11 | "styleWith", 12 | "utilities", 13 | ] 14 | `) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /packages/benefit/README.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | ```bash 4 | yarn add benefit 5 | ``` 6 | 7 | Import and use the `createBenefit` function to create your utility classes 8 | 9 | ``` 10 | import { createBenefit } from "benefit" 11 | 12 | const { styleWith } = createBenefit() 13 | ``` 14 | 15 | Use `styleWith(...)` to pass in utility classes 16 | 17 | ``` 18 |
19 | ... 20 |
21 | ``` 22 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/Logo.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | import svgUrl from "../benefit-logo.svg" 4 | import svgUrlDark from "../benefit-logo-dark.svg" 5 | 6 | export default function BenefitLogo({ className, isDark }) { 7 | return ( 8 | 14 | ) 15 | } 16 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/Logo.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | import svgUrl from "../benefit-logo.svg" 4 | import svgUrlDark from "../benefit-logo-dark.svg" 5 | 6 | export default function BenefitLogo({ className, isDark }) { 7 | return ( 8 | 14 | ) 15 | } 16 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/borderColor.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | import flattenColorConfig from "../flattenColorConfig" 3 | 4 | export default function generate(theme: any) { 5 | const { borderColor = {} } = theme 6 | return createUtilitiesFromMap( 7 | flattenColorConfig(borderColor), 8 | (value: string) => ({ 9 | "border-color": value, 10 | }), 11 | "border" 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/Tablet.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box, css } from "benefit-react" 3 | 4 | export default function Tablet(props) { 5 | return ( 6 | 7 | 8 | {props.children} 9 | 10 | 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/benefit-docs/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from "react" 2 | import { renderToString } from "react-dom/server" 3 | import { ServerStyleManager } from "benefit-react" 4 | 5 | export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => { 6 | const app = () => ( 7 | 8 | 9 | {bodyComponent} 10 | 11 | ) 12 | replaceBodyHTMLString(renderToString()) 13 | } 14 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/backgroundColor.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | import flattenColorConfig from "../flattenColorConfig" 3 | 4 | export default function generate(theme: any) { 5 | const { backgroundColor = {} } = theme 6 | return createUtilitiesFromMap( 7 | flattenColorConfig(backgroundColor), 8 | (value: string) => ({ 9 | "background-color": value, 10 | }), 11 | "bg" 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/cursor.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { cursor = {} } = theme 5 | 6 | return { 7 | "cursor-default": { 8 | cursor: "default", 9 | }, 10 | ...createUtilitiesFromMap( 11 | cursor, 12 | (value: string) => ({ 13 | cursor: value, 14 | }), 15 | "cursor" 16 | ), 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/wordBreak.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "break-normal": { "overflow-wrap": "normal", "word-break": "normal" }, 4 | "break-words": { "overflow-wrap": "break-word" }, 5 | "break-all": { 6 | "word-break": "break-all", 7 | }, 8 | 9 | truncate: { 10 | overflow: "hidden", 11 | "text-overflow": "ellipsis", 12 | "white-space": "nowrap", 13 | }, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/examples/with-next/pages/about.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from "benefit-react" 3 | 4 | function About() { 5 | return ( 6 |
7 | Welcome to About{" "} 8 | 12 | Back Home 13 | {" "} 14 |
15 | ) 16 | } 17 | 18 | export default About 19 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/doczTheme.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { theme, ThemeConfig, DocPreview } from "docz" 3 | import { ThemeProvider } from "emotion-theming" 4 | import Menu from "./theme/Menu" 5 | 6 | const Theme = () => ( 7 | 8 | {(config) => ( 9 | 10 | 11 | 12 | 13 | )} 14 | 15 | ) 16 | 17 | export default theme()(Theme) 18 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/float.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate() { 4 | return { 5 | clearfix: { 6 | "&::after": { 7 | content: "''", 8 | display: "table", 9 | clear: "both", 10 | }, 11 | }, 12 | ...createUtilitiesFromMap( 13 | ["right", "left", "none"], 14 | (value: string) => ({ float: value }), 15 | "float" 16 | ), 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/examples/with-next/pages/_document.js: -------------------------------------------------------------------------------- 1 | import Document, { Html, Head, Main, NextScript } from "next/document" 2 | import { StylesContainer } from "benefit-react" 3 | 4 | export default class MyDocument extends Document { 5 | render() { 6 | return ( 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | ) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit/util/createUtilityMap.ts: -------------------------------------------------------------------------------- 1 | export default function createUtilityMap( 2 | allUtilities: Array<(theme?: Object) => Object> = [], 3 | theme: Object = {} 4 | ): Object { 5 | const map: any = {} 6 | for (let i = 0; i < allUtilities.length; i++) { 7 | const utilityFn = allUtilities[i] 8 | const rulesMap: any = utilityFn(theme) || {} 9 | 10 | Object.keys(rulesMap).forEach(key => { 11 | map[key] = rulesMap[key] 12 | }) 13 | } 14 | 15 | return map 16 | } 17 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/move.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/move.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/util/createVariantMap.ts: -------------------------------------------------------------------------------- 1 | export default function createVariantMap( 2 | allVariants: Array = [], 3 | utilityMap: Object = {}, 4 | theme: Object = {} 5 | ): Object { 6 | const map: any = {} 7 | for (let i = 0; i < allVariants.length; i++) { 8 | const variantFn = allVariants[i] 9 | const rulesMap = variantFn(utilityMap, theme) || {} 10 | 11 | Object.keys(rulesMap).forEach(key => { 12 | map[key] = rulesMap[key] 13 | }) 14 | } 15 | 16 | return map 17 | } 18 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "benefit-docs-old", 4 | "version": "1.1.1", 5 | "scripts": { 6 | "start": "docz dev", 7 | "build": "docz build" 8 | }, 9 | "dependencies": { 10 | "benefit": "*", 11 | "benefit-react": "*" 12 | }, 13 | "devDependencies": { 14 | "docz": "1.2.0", 15 | "react": "16.8.6", 16 | "react-dom": "16.8.6", 17 | "emotion": "10.0.14", 18 | "polychrome": "4.1.2", 19 | "ts-loader": "6.0.4" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/Grid.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function Grid({ children, className, minWidth = "1fr" }) { 5 | return ( 6 | 15 | {children} 16 | 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/display.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | const displayVariants = [ 4 | "block", 5 | "inline-block", 6 | "inline", 7 | "table", 8 | "table-row", 9 | "table-cell", 10 | "flex", 11 | "inline-flex", 12 | ] 13 | 14 | export default function generate() { 15 | return { 16 | ...createUtilitiesFromMap(displayVariants, (value: string) => ({ 17 | display: value, 18 | })), 19 | hidden: { display: "none" }, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/container.ts: -------------------------------------------------------------------------------- 1 | export default function generate(theme: any) { 2 | const { screens = {} } = theme 3 | 4 | return { 5 | container: { 6 | width: "100%", 7 | ...Object.keys(screens).reduce( 8 | (mediaQueries, containerSize) => ({ 9 | ...mediaQueries, 10 | [`@media (min-width: ${screens[containerSize]})`]: { 11 | "max-width": screens[containerSize], 12 | }, 13 | }), 14 | {} 15 | ), 16 | }, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/github.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/github.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/normalize.ts: -------------------------------------------------------------------------------- 1 | export default function normalize(theme: any) { 2 | return { 3 | margin: "0", 4 | padding: "0", 5 | "border-width": "0", 6 | "border-style": "solid", 7 | "border-color": 8 | (theme && theme.borderColor && theme.borderColor.default) || "black", 9 | color: "inherit", 10 | "font-family": "inherit", 11 | "font-size": "inherit", 12 | "font-weight": "inherit", 13 | "line-height": "inherit", 14 | "vertical-align": "baseline", 15 | "box-sizing": "border-box", 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/flex.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { flex = {}, order = {} } = theme 5 | 6 | return { 7 | ...createUtilitiesFromMap( 8 | flex, 9 | (value: string) => ({ 10 | flex: value, 11 | }), 12 | "flex" 13 | ), 14 | 15 | ...createUtilitiesFromMap( 16 | order, 17 | (value: string) => ({ 18 | order: value, 19 | }), 20 | "order" 21 | ), 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/theme/Menu.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Docs, Link } from "docz" 3 | import { Box } from "benefit-react" 4 | 5 | export default function Menu() { 6 | return ( 7 | 8 | {({ docs }) => ( 9 | Benefit 10 | //
    11 | // {docs.map((doc) => ( 12 | //
  • 13 | // {doc.name} 14 | //
  • 15 | // ))} 16 | //
17 | )} 18 |
19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/backgroundRepeat.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | const backgroundRepeat = { 4 | repeat: "repeat", 5 | "repeat-round": "round", 6 | "repeat-space": "space", 7 | "no-repeat": "no-repeat", 8 | "repeat-x": "repeat-x", 9 | "repeat-y": "repeat-y", 10 | space: "space", 11 | round: "round", 12 | } 13 | 14 | export default function generate() { 15 | return createUtilitiesFromMap( 16 | backgroundRepeat, 17 | (value: string) => ({ 18 | "background-repeat": value, 19 | }), 20 | "bg" 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/installation.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Install 3 | route: /installation/ 4 | previousRoute: / 5 | previousLabel: Introduction 6 | nextRoute: /customization/overview/ 7 | nextLabel: Customization 8 | --- 9 | 10 | `benefit` can be consumed in a few different ways: 11 | 12 | ## Framework agnostic 13 | 14 | ```bash 15 | npm i benefit 16 | ``` 17 | 18 | ## React 19 | 20 | ```bash 21 | npm i benefit-react 22 | ``` 23 | 24 | This provides some additional wrappers and is preferred for `React` applications, but also exposes the core functionality from the framework agnostic `benefit` package. 25 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/interactivity/cursor.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Cursor 3 | property: cursor 4 | parent: Interactivity 5 | route: /interactivity/cursor/ 6 | previousRoute: /interactivity/appearance/ 7 | previousLabel: Appearance 8 | nextRoute: /interactivity/outline/ 9 | nextLabel: Outline 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | Hover here to see the cursor change 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/loader.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/loader.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/benefit/config/createVariantsFromMap.ts: -------------------------------------------------------------------------------- 1 | import createVariant from "./createVariant" 2 | 3 | export default function createVariantsFromMap( 4 | utilities: any, 5 | map: any, 6 | generateDeclarations: any 7 | ) { 8 | if (!map) { 9 | return {} 10 | } 11 | return Object.keys(map).reduce((variants: any, key) => { 12 | const v = createVariant( 13 | utilities, 14 | (value: any) => generateDeclarations(map[key], value), 15 | key 16 | ) 17 | 18 | Object.keys(v).forEach((className) => { 19 | variants[className] = v[className] 20 | }) 21 | 22 | return variants 23 | }, {}) 24 | } 25 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/Icon.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx, css } from "benefit-react" 3 | import sprites from "../svg/sprites.svg" 4 | 5 | const iconStyles = css` 6 | width: 24px; 7 | height: 24px; 8 | stroke: currentColor; 9 | stroke-width: 2; 10 | stroke-linecap: round; 11 | stroke-linejoin: round; 12 | fill: none; 13 | ` 14 | 15 | export default function Icon(props) { 16 | const { className, name, ...remainingProps } = props 17 | 18 | return ( 19 | 20 | 21 | 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /packages/benefit/config/createUtilitiesFromMap.ts: -------------------------------------------------------------------------------- 1 | export default function createUtilitiesFromMap( 2 | map: any = {}, 3 | generateDeclarations: any, 4 | prefix: any = "" 5 | ) { 6 | if (!map) { 7 | return {} 8 | } 9 | return Object.keys(map).reduce((utilities: any, key) => { 10 | const value = map[key] 11 | const label = Array.isArray(map) ? value : key 12 | const className = [prefix, label === "default" ? null : label] 13 | .filter(Boolean) 14 | .join("-") 15 | 16 | const declarations = generateDeclarations(value) 17 | 18 | utilities[className] = declarations 19 | 20 | return utilities 21 | }, {}) 22 | } 23 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/Icons.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { css } from "emotion" 3 | import { jsx } from "benefit-react" 4 | import sprites from "../svg/sprites.svg" 5 | 6 | const iconStyles = css` 7 | width: 24px; 8 | height: 24px; 9 | stroke: currentColor; 10 | stroke-width: 2; 11 | stroke-linecap: round; 12 | stroke-linejoin: round; 13 | fill: none; 14 | ` 15 | 16 | export default function Icon(props) { 17 | const { className, name, ...remainingProps } = props 18 | 19 | return ( 20 | 21 | 22 | 23 | ) 24 | } 25 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/installation/agnostic.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Framework Agnostic 3 | route: /installation/agnostic/ 4 | parent: Installation 5 | previousRoute: / 6 | previousLabel: Introduction 7 | nextRoute: /installation/react/ 8 | nextLabel: React 9 | --- 10 | 11 | ```bash 12 | npm i benefit 13 | ``` 14 | 15 | `createBenefit` is a function that will return a `styleWith` property that you can call as a function. Use this when you want to output any utility classes to your elements/components. 16 | 17 | ```js 18 | import { createBenefit } from "benefit" 19 | 20 | const { styleWith } = createBenefit() 21 | 22 |
...
23 | ``` 24 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/width.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { width = {}, maxWidth = {}, minWidth = {} } = theme 5 | return { 6 | ...createUtilitiesFromMap( 7 | width, 8 | (value: string) => ({ 9 | width: value, 10 | }), 11 | "w" 12 | ), 13 | ...createUtilitiesFromMap( 14 | maxWidth, 15 | (value: string) => ({ 16 | "max-width": value, 17 | }), 18 | "max-w" 19 | ), 20 | ...createUtilitiesFromMap( 21 | minWidth, 22 | (value: string) => ({ 23 | "min-width": value, 24 | }), 25 | "min-w" 26 | ), 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/theme/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ title }} 9 | 22 | {{head}} 23 | 24 | 25 |
26 | {{footer}} 27 | 28 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/height.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { height = {}, maxHeight = {}, minHeight = {} } = theme 5 | return { 6 | ...createUtilitiesFromMap( 7 | height, 8 | (value: string) => ({ 9 | height: value, 10 | }), 11 | "h" 12 | ), 13 | ...createUtilitiesFromMap( 14 | maxHeight, 15 | (value: string) => ({ 16 | "max-height": value, 17 | }), 18 | "max-h" 19 | ), 20 | ...createUtilitiesFromMap( 21 | minHeight, 22 | (value: string) => ({ 23 | "min-height": value, 24 | }), 25 | "min-h" 26 | ), 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/Phone.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function Phone(props) { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | {props.children} 12 | 13 | 14 | 15 | 16 | 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/Phone.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function Phone(props) { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | {props.children} 12 | 13 | 14 | 15 | 16 | 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/Tablet.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function Tablet(props) { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | {props.children} 12 | 13 | 14 | 15 | 16 | 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit/config/flattenColorConfig.ts: -------------------------------------------------------------------------------- 1 | function flattenColor(name: any, value: any) { 2 | if (typeof value !== "object") { 3 | return { 4 | [name]: value, 5 | } 6 | } 7 | 8 | return Object.keys(value).reduce( 9 | (colorVariants, colorVariation) => ({ 10 | ...colorVariants, 11 | [`${name}${ 12 | colorVariation !== "default" ? `-${colorVariation}` : "" 13 | }`]: value[colorVariation], 14 | }), 15 | {} 16 | ) 17 | } 18 | 19 | export default function flattenColorConfig(colorConfig: any = {}) { 20 | return Object.keys(colorConfig).reduce( 21 | (colors, colorName) => ({ 22 | ...colors, 23 | ...flattenColor(colorName, colorConfig[colorName]), 24 | }), 25 | {} 26 | ) 27 | } 28 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/Grid.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box, css, keyframes } from "benefit-react" 3 | 4 | const fadeInLeft = keyframes` 5 | from { 6 | opacity: 0; 7 | transform: translateY(20px); 8 | } 9 | 10 | to { 11 | opacity: 1; 12 | transform: translateY(0); 13 | } 14 | ` 15 | 16 | export default function Grid({ 17 | children, 18 | className, 19 | minWidth = "1fr", 20 | stagger = true, 21 | }) { 22 | return ( 23 | 31 | {children} 32 | 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/BrowserBox.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function BrowserBox({ children }) { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {children} 15 | 16 | 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/BrowserBox.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function BrowserBox({ children }) { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {children} 15 | 16 | 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/border/border-color.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Border Color 3 | property: border-color 4 | parent: Border 5 | route: /border/border-color/ 6 | previousRoute: /background/background-size/ 7 | previousLabel: Background Size 8 | nextRoute: /border/border-radius/ 9 | nextLabel: Border Radius 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | _Shown here using the `blue` palette_ 17 | 18 | 19 | {[...Array(9).keys()].reverse().map(level => ( 20 | 21 | 25 | 26 | ))} 27 | 28 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/background/background-color.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Background Color 3 | property: background-color 4 | parent: Background 5 | route: /background/background-color/ 6 | previousRoute: /background/background-attachment/ 7 | previousLabel: Background Attachment 8 | nextRoute: /background/background-position/ 9 | nextLabel: Background Position 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | _Shown here using the `blue` palette_ 17 | 18 | 19 | {[...Array(9).keys()].reverse().map(level => ( 20 | 21 | 25 | 26 | ))} 27 | 28 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/typography/font-size.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Font Size 3 | property: font-size 4 | parent: Typography 5 | route: /typography/font-size/ 6 | previousRoute: /typography/font-family/ 7 | previousLabel: Font Family 8 | nextRoute: /typography/font-weight/ 9 | nextLabel: Font Weight 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | {({ config }) => ( 18 | 19 | {Object.keys(config.theme.fontSize).map(size => ( 20 | 21 | 22 | The five boxing wizards jump quickly. 23 | 24 | 25 | ))} 26 | 27 | )} 28 | 29 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/typography/font-weight.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Font Weight 3 | property: font-weight 4 | parent: Typography 5 | route: /typography/font-weight/ 6 | previousRoute: /typography/font-size/ 7 | previousLabel: Font Size 8 | nextRoute: /typography/letter-spacing/ 9 | nextLabel: Letter Spacing 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | {({ config }) => ( 18 | 19 | {Object.keys(config.theme.fontWeight).map(weight => ( 20 | 21 | 22 | Pack my box with five dozen liquor jugs. 23 | 24 | 25 | ))} 26 | 27 | )} 28 | 29 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/typography/font-family.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Font Family 3 | property: font-family 4 | parent: Typography 5 | route: /typography/font-family/ 6 | previousRoute: /layout/z-index/ 7 | previousLabel: Z Index 8 | nextRoute: /typography/font-size/ 9 | nextLabel: Font Size 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | Pack my box with five dozen liquor jugs. 19 | 20 | 21 | 22 | Pack my box with five dozen liquor jugs. 23 | 24 | 25 | 26 | Pack my box with five dozen liquor jugs. 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/typography/text-color.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Text Color 3 | property: color 4 | parent: Typography 5 | route: /typography/text-color/ 6 | previousRoute: /typography/text-alignment/ 7 | previousLabel: Text Alignment 8 | nextRoute: /typography/vertical-alignment/ 9 | nextLabel: Vertical Alignment 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | _Shown here using the `blue` palette_ 17 | 18 | 19 | {[...Array(9).keys()].reverse().map(level => ( 20 | 21 | 25 | Pack my box with five dozen liquor jugs. 26 | 27 | 28 | ))} 29 | 30 | -------------------------------------------------------------------------------- /packages/benefit/util/parseDeclarations.ts: -------------------------------------------------------------------------------- 1 | export function formatDeclaration( 2 | property: string, 3 | value: string, 4 | isImportant: boolean = false 5 | ): string { 6 | const declaration = `${property}: ${value}` 7 | return `${declaration}${isImportant ? " !important" : ""};` 8 | } 9 | 10 | export default function parseDeclarations( 11 | declarations: any = {}, 12 | isImportant: boolean = false 13 | ): Array { 14 | return Object.keys(declarations).map(property => { 15 | if (property.match(/[&@]/)) { 16 | // Assume we have a nested selector 17 | const nestedDeclarations = parseDeclarations( 18 | declarations[property], 19 | isImportant 20 | ) 21 | 22 | return `${property} { ${nestedDeclarations.join("")} }` 23 | } 24 | 25 | return formatDeclaration(property, declarations[property], isImportant) 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/layout/visibility.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Visibility 3 | property: visibility 4 | parent: Layout 5 | route: /layout/visibility/ 6 | previousRoute: /layout/position/ 7 | previousLabel: Position 8 | nextRoute: /layout/z-index/ 9 | nextLabel: Z Index 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | > Dotted lines are only shown here to demonstrate that while the `invisible` element is hidden from view, it still takes up space in the document. 26 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/typography/letter-spacing.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Letter Spacing 3 | property: letter-spacing 4 | parent: Typography 5 | route: /typography/letter-spacing/ 6 | previousRoute: /typography/font-weight/ 7 | previousLabel: Font Weight 8 | nextRoute: /typography/line-height/ 9 | nextLabel: Line Height 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | {({ config }) => ( 18 | 19 | {Object.keys(config.theme.letterSpacing).map(size => ( 20 | 21 | 22 | Pack my box with five dozen liquor jugs. 23 | 24 | 25 | ))} 26 | 27 | )} 28 | 29 | -------------------------------------------------------------------------------- /packages/benefit/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["."], 3 | "exclude": ["node_modules", "dist", "build"], 4 | "compilerOptions": { 5 | "composite": true, 6 | "target": "es5", 7 | "module": "esnext", 8 | "lib": ["dom", "esnext"], 9 | "importHelpers": true, 10 | "sourceMap": true, 11 | "rootDir": "./", 12 | "strict": true, 13 | "noImplicitAny": true, 14 | "strictNullChecks": true, 15 | "strictFunctionTypes": true, 16 | "strictPropertyInitialization": true, 17 | "noImplicitThis": true, 18 | "alwaysStrict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noImplicitReturns": true, 22 | "noFallthroughCasesInSwitch": false, 23 | "moduleResolution": "node", 24 | "baseUrl": "./", 25 | "paths": { 26 | "*": ["node_modules/*"] 27 | }, 28 | "esModuleInterop": true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/overflow.ts: -------------------------------------------------------------------------------- 1 | export default function generate() { 2 | return { 3 | "overflow-auto": { overflow: "auto" }, 4 | "overflow-hidden": { overflow: "hidden" }, 5 | "overflow-visible": { overflow: "visible" }, 6 | "overflow-scroll": { overflow: "scroll" }, 7 | "overflow-x-auto": { "overflow-x": "auto" }, 8 | "overflow-y-auto": { "overflow-y": "auto" }, 9 | "overflow-x-hidden": { "overflow-x": "hidden" }, 10 | "overflow-y-hidden": { "overflow-y": "hidden" }, 11 | "overflow-x-visible": { "overflow-x": "visible" }, 12 | "overflow-y-visible": { "overflow-y": "visible" }, 13 | "overflow-x-scroll": { "overflow-x": "scroll" }, 14 | "overflow-y-scroll": { "overflow-y": "scroll" }, 15 | "scrolling-touch": { "-webkit-overflow-scrolling": "touch" }, 16 | "scrolling-auto": { "-webkit-overflow-scrolling": "auto" }, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/benefit/index.ts: -------------------------------------------------------------------------------- 1 | import createBenefit from "./createBenefit" 2 | import createUtilitiesFromMap from "./config/createUtilitiesFromMap" 3 | import createVariant from "./config/createVariant" 4 | import createVariantsFromMap from "./config/createVariantsFromMap" 5 | import { css, injectGlobal, keyframes, injectPreflight } from "./util/css" 6 | import { generatePreflightStyles } from "./util/preflight" 7 | import registry from "./util/registry" 8 | import flattenColorConfig from "./config/flattenColorConfig" 9 | import parseDeclarations from "./util/parseDeclarations" 10 | import theme from "./config/theme" 11 | 12 | export { 13 | createBenefit, 14 | createUtilitiesFromMap, 15 | createVariant, 16 | createVariantsFromMap, 17 | css, 18 | flattenColorConfig, 19 | injectGlobal, 20 | injectPreflight, 21 | keyframes, 22 | parseDeclarations, 23 | generatePreflightStyles, 24 | registry, 25 | theme, 26 | } 27 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/interactivity/cursor.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Cursor 3 | property: cursor 4 | parent: Interactivity 5 | route: /interactivity/cursor 6 | previousRoute: /interactivity/appearance 7 | previousLabel: Appearance 8 | nextRoute: /interactivity/outline 9 | nextLabel: Outline 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box, ConfigConsumer } from "benefit-react" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | import ConfigPropertyList from "../../components/ConfigPropertyList" 17 | import UtilityInfo from "../../components/UtilityInfo" 18 | 19 | 20 | 21 | --- 22 | 23 | 24 | 25 | Hover here to see the cursor change 26 | 27 | 28 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/layout/container.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Container 3 | property: max-width 4 | parent: Layout 5 | route: /layout/container/ 6 | previousRoute: /customization/apply/ 7 | previousLabel: Apply 8 | nextRoute: /layout/display/ 9 | nextLabel: Display 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | Containers provide a nice, responsive way to wrap your content. Add a `container` class to make an element's `max-width` match the `min-width` of the current breakpoint. All containers have a `width: 100%` applied. 17 | 18 | ```html 19 |
20 |

21 | Business at the speed of light. 22 |

23 |
24 | ``` 25 | 26 | > The above `container` has a utility of `mx-auto` added so it is centered horizontally within the parent. 27 | -------------------------------------------------------------------------------- /packages/benefit-react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["."], 3 | "exclude": ["node_modules", "dist", "build"], 4 | "compilerOptions": { 5 | "target": "es5", 6 | "module": "esnext", 7 | "lib": ["dom", "esnext"], 8 | "importHelpers": true, 9 | "sourceMap": true, 10 | "rootDir": "./", 11 | "strict": true, 12 | "noImplicitAny": true, 13 | "strictNullChecks": true, 14 | "strictFunctionTypes": true, 15 | "strictPropertyInitialization": true, 16 | "noImplicitThis": true, 17 | "alwaysStrict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noImplicitReturns": true, 21 | "noFallthroughCasesInSwitch": true, 22 | "moduleResolution": "node", 23 | "baseUrl": "./", 24 | "paths": { 25 | "*": ["node_modules/*"] 26 | }, 27 | "jsx": "react", 28 | "esModuleInterop": true 29 | }, 30 | "references": [{ "path": "../benefit" }] 31 | } 32 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/svg/flex.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | grid 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/header.js: -------------------------------------------------------------------------------- 1 | import { Link } from "gatsby" 2 | import PropTypes from "prop-types" 3 | import React from "react" 4 | 5 | const Header = ({ siteTitle }) => ( 6 |
12 |
19 |

20 | 27 | {siteTitle} 28 | 29 |

30 |
31 |
32 | ) 33 | 34 | Header.propTypes = { 35 | siteTitle: PropTypes.string, 36 | } 37 | 38 | Header.defaultProps = { 39 | siteTitle: ``, 40 | } 41 | 42 | export default Header 43 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/svg/flex.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | grid 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/with-jsx/main.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | 3 | import { render } from "react-dom" 4 | import { css } from "@emotion/core" 5 | import { jsx } from "../../dist/react" 6 | 7 | function App() { 8 | return ( 9 |
10 |
16 |

17 | Dolor Sit Amet 18 |

19 |
20 |
21 |

27 | Lorem Ipsum 28 |

29 |
30 |
31 | ) 32 | } 33 | 34 | render(, document.getElementById("root")) 35 | -------------------------------------------------------------------------------- /examples/with-next/pages/index.js: -------------------------------------------------------------------------------- 1 | import { react, css } from "../../../dist/benefit.esm" 2 | 3 | const { jsx } = react 4 | 5 | function Home() { 6 | return ( 7 |
8 | Welcome to Next.js! Click{" "} 9 | 13 | here 14 | {" "} 15 | to read more 16 |
22 | lorem ipsum 23 |
24 |
30 | Hello 31 |
32 |
World
33 |
34 | ) 35 | } 36 | 37 | export default Home 38 | -------------------------------------------------------------------------------- /packages/benefit-react/index.ts: -------------------------------------------------------------------------------- 1 | import ConfigContext, { ConfigConsumer, ConfigProvider } from "./ConfigContext" 2 | import ServerStyleManager from "./ServerStyleManager" 3 | import Box from "./Box" 4 | import jsx from "./jsx" 5 | import Preflight from "./Preflight" 6 | 7 | import { 8 | createBenefit, 9 | createUtilitiesFromMap, 10 | createVariant, 11 | createVariantsFromMap, 12 | flattenColorConfig, 13 | css, 14 | injectGlobal, 15 | injectPreflight, 16 | registry, 17 | keyframes, 18 | parseDeclarations, 19 | theme, 20 | } from "benefit" 21 | 22 | export { 23 | ConfigContext, 24 | ConfigConsumer, 25 | ConfigProvider, 26 | ServerStyleManager, 27 | Box, 28 | jsx, 29 | registry, 30 | createBenefit, 31 | createUtilitiesFromMap, 32 | createVariant, 33 | createVariantsFromMap, 34 | css, 35 | keyframes, 36 | flattenColorConfig, 37 | parseDeclarations, 38 | injectGlobal, 39 | injectPreflight, 40 | Preflight, 41 | theme, 42 | } 43 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/introduction.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Introduction 3 | route: / 4 | nextRoute: /getting-started 5 | nextLabel: Getting Started 6 | showLogo: true 7 | --- 8 | 9 | import { Box, ConfigProvider } from "benefit-react" 10 | import Logo from "./components/Logo" 11 | import Alert from "./components/Alert" 12 | import { Playground, Link } from "docz" 13 | import Output from "./components/Output" 14 | 15 | ## Style web applications using generated utility classes 16 | 17 | `benefit` is a _5Kb_, utility CSS library that is compatible with TailwindCSS. 18 | 19 | - Small runtime 20 | - No build step 21 | - Element [normalization](/customization/normalize) 22 | - Style isolation 23 | - Fully [Customizable](/customization/overview) 24 | - Works with [TailwindCSS](https://tailwindcss.com) class names out of box 25 | 26 | And... it only inlines the CSS for the utilities that you actually use: 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/InfoBox.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from "benefit-react" 3 | 4 | export default function LayoutBox({ 5 | color = "gray", 6 | caption, 7 | children, 8 | pattern, 9 | isDefault, 10 | className, 11 | }) { 12 | return ( 13 |
16 | {isDefault && ( 17 |
20 | Default 21 |
22 | )} 23 | {caption && ( 24 |

25 | {caption} 26 |

27 | )} 28 | {pattern && ( 29 | {pattern} 30 | )} 31 |
{children}
32 |
33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/border/border-style.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Border Style 3 | property: border-style 4 | parent: Border 5 | route: /border/border-style/ 6 | previousRoute: /border/border-radius/ 7 | previousLabel: Border Radius 8 | nextRoute: /border/border-width/ 9 | nextLabel: Border Width 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/effects/opacity.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Opacity 3 | property: opacity 4 | parent: Effects 5 | route: /effects/opacity/ 6 | previousRoute: /effects/box-shadow/ 7 | previousLabel: Box Shadow 8 | nextRoute: /interactivity/appearance/ 9 | nextLabel: Appearance 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | opacity-100 19 | 20 | 21 | opacity-75 22 | 23 | 24 | opacity-50 25 | 26 | 27 | opacity-25 28 | 29 | 30 | opacity-0 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/typography/line-height.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Line Height 3 | property: line-height 4 | parent: Typography 5 | route: /typography/line-height/ 6 | previousRoute: /typography/letter-spacing/ 7 | previousLabel: Letter Spacing 8 | nextRoute: /typography/lists/ 9 | nextLabel: Lists 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | {({ config }) => ( 18 | 19 | {Object.keys(config.theme.lineHeight).map(size => ( 20 | 21 | 22 | Portland flannel trust fund plaid kitsch. Hot chicken everyday carry 23 | williamsburg YOLO green juice lomo. Bicycle rights man bun +1 shabby 24 | chic migas salvia listicle polaroid paleo. 25 | 26 | 27 | ))} 28 | 29 | )} 30 | 31 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/theme/components/Loader.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { css, keyframes } from "emotion" 3 | import { jsx } from "benefit-react" 4 | 5 | const scale = keyframes` 6 | 0% { 7 | transform: scale(0.0); 8 | opacity: 0; 9 | } 10 | 5% { 11 | opacity: 1; 12 | } 13 | 100% { 14 | transform: scale(1.0); 15 | opacity: 0; 16 | } 17 | ` 18 | 19 | const ball = css` 20 | position: absolute; 21 | left: -30px; 22 | top: 0; 23 | opacity: 0; 24 | margin: 0; 25 | width: 60px; 26 | height: 60px; 27 | background: red; 28 | border-radius: 100%; 29 | animation: ${scale} 1s 0s linear infinite; 30 | 31 | &:nth-of-type(2) { 32 | animation-delay: -0.4s; 33 | } 34 | 35 | &:nth-child(3) { 36 | animation-delay: -0.2s; 37 | } 38 | ` 39 | 40 | export default function Loader() { 41 | return ( 42 |
43 |
44 |
45 |
46 |
47 | ) 48 | } 49 | -------------------------------------------------------------------------------- /packages/benefit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "benefit", 3 | "version": "2.2.1", 4 | "main": "dist/index.js", 5 | "module": "dist/benefit.esm.js", 6 | "types": "dist/index.d.ts", 7 | "repository": "https://github.com/cdonohue/benefit.git", 8 | "contributors": [ 9 | "Chad Donohue ", 10 | "Eric Clemmons " 11 | ], 12 | "description": "Utility CSS library that provides a set of low-level, configurable, ready-to-use styles.", 13 | "license": "MIT", 14 | "keywords": [ 15 | "atomic", 16 | "css", 17 | "css-in-js", 18 | "design", 19 | "emotion", 20 | "system", 21 | "tailwind", 22 | "tailwindcss", 23 | "utility-classes" 24 | ], 25 | "files": [ 26 | "dist" 27 | ], 28 | "scripts": { 29 | "prebuild": "rimraf dist", 30 | "build": "node ../../scripts/build benefit", 31 | "prerelease": "yarn build", 32 | "release": "np" 33 | }, 34 | "sideEffects": false, 35 | "dependencies": { 36 | "stylis": "3.5.4" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/layout/visibility.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Visibility 3 | property: visibility 4 | parent: Layout 5 | route: /layout/visibility 6 | previousRoute: /layout/position 7 | previousLabel: Position 8 | nextRoute: /layout/z-index 9 | nextLabel: Z Index 10 | --- 11 | 12 | import { Box } from "benefit-react" 13 | import Grid from "../../components/Grid" 14 | import InfoBox from "../../components/InfoBox" 15 | 16 | import UtilityInfo from "../../components/UtilityInfo" 17 | 18 | 19 | 20 | --- 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | > Dotted lines are only shown here to demonstrate that while the `invisible` element is hidden from view, it still takes up space in the document. 32 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/background/background-color.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Background Color 3 | property: background-color 4 | parent: Background 5 | route: /background/background-color 6 | previousRoute: /background/background-attachment 7 | previousLabel: Background Attachment 8 | nextRoute: /background/background-position 9 | nextLabel: Background Position 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import InfoBox from "../../components/InfoBox" 14 | import Grid from "../../components/Grid" 15 | import { Box } from "benefit-react" 16 | import UtilityInfo from "../../components/UtilityInfo" 17 | 18 | 19 | 20 | --- 21 | 22 | _Shown here using the `blue` palette_ 23 | 24 | 25 | {[...Array(9).keys()].reverse().map((level) => ( 26 | 27 | 31 | 32 | ))} 33 | 34 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/svg/stroke.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Stroke 3 | property: stroke 4 | parent: Svg 5 | route: /svg/stroke/ 6 | previousRoute: /svg/fill/ 7 | previousLabel: Fill 8 | --- 9 | 10 | 11 | 12 | --- 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /packages/examples/with-next/pages/_app.js: -------------------------------------------------------------------------------- 1 | import App from "next/app" 2 | import { ConfigProvider, Preflight } from "benefit-react" 3 | import polychrome from "polychrome" 4 | 5 | export default class MyApp extends App { 6 | render() { 7 | const { Component, pageProps } = this.props 8 | 9 | const primary = "#232323" 10 | 11 | const colors = { 12 | primary, 13 | "primary-contrast": polychrome(primary) 14 | .contrast() 15 | .hex(), 16 | } 17 | 18 | return ( 19 | ({ 21 | ...config, 22 | theme: { 23 | ...config.theme, 24 | backgroundColor: { 25 | ...config.theme.backgroundColor, 26 | ...colors, 27 | }, 28 | textColor: { 29 | ...config.theme.textColor, 30 | ...colors, 31 | }, 32 | }, 33 | })} 34 | > 35 | 36 | 37 | 38 | ) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/typography/font-family.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Font Family 3 | property: font-family 4 | parent: Typography 5 | route: /typography/font-family 6 | previousRoute: /layout/z-index 7 | previousLabel: Z Index 8 | nextRoute: /typography/font-size 9 | nextLabel: Font Size 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box, ConfigConsumer } from "benefit-react" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | import UtilityInfo from "../../components/UtilityInfo" 17 | 18 | 19 | 20 | --- 21 | 22 | 23 | Pack my box with five dozen liquor jugs. 24 | 25 | 26 | 27 | Pack my box with five dozen liquor jugs. 28 | 29 | 30 | 31 | Pack my box with five dozen liquor jugs. 32 | 33 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/InfoBox.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { Box } from "benefit-react" 3 | 4 | export default function LayoutBox({ 5 | color = "gray", 6 | caption, 7 | children, 8 | pattern, 9 | isDefault, 10 | className, 11 | }) { 12 | return ( 13 | 16 | {isDefault && ( 17 | 20 | Default 21 | 22 | )} 23 | {caption && ( 24 | 28 | {caption} 29 | 30 | )} 31 | {pattern && ( 32 | 33 | {pattern} 34 | 35 | )} 36 | {children} 37 | 38 | ) 39 | } 40 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/typography/text-color.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Text Color 3 | property: color 4 | parent: Typography 5 | route: /typography/text-color 6 | previousRoute: /typography/text-alignment 7 | previousLabel: Text Alignment 8 | nextRoute: /typography/vertical-alignment 9 | nextLabel: Vertical Alignment 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box } from "benefit-react" 14 | import Grid from "../../components/Grid" 15 | import InfoBox from "../../components/InfoBox" 16 | import UtilityInfo from "../../components/UtilityInfo" 17 | 18 | 19 | 20 | --- 21 | 22 | _Shown here using the `blue` palette_ 23 | 24 | 25 | {[...Array(9).keys()].reverse().map((level) => ( 26 | 27 | 31 | Pack my box with five dozen liquor jugs. 32 | 33 | 34 | ))} 35 | 36 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/border/border-color.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Border Color 3 | property: border-color 4 | parent: Border 5 | route: /border/border-color 6 | previousRoute: /background/background-size 7 | previousLabel: Background Size 8 | nextRoute: /border/border-radius 9 | nextLabel: Border Radius 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import ConfigPropertyList from "../../components/ConfigPropertyList" 14 | import Grid from "../../components/Grid" 15 | import InfoBox from "../../components/InfoBox" 16 | import { Box, ConfigConsumer } from "benefit-react" 17 | 18 | import UtilityInfo from "../../components/UtilityInfo" 19 | 20 | 21 | 22 | --- 23 | 24 | _Shown here using the `blue` palette_ 25 | 26 | 27 | {[...Array(9).keys()].reverse().map((level) => ( 28 | 29 | 33 | 34 | ))} 35 | 36 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/svg/fill.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Fill 3 | property: fill 4 | parent: Svg 5 | route: /svg/fill/ 6 | previousRoute: /interactivity/user-select/ 7 | previousLabel: User Select 8 | nextRoute: /svg/stroke/ 9 | nextLabel: Stroke 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/borderWidth.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { borderWidth = {} } = theme 5 | return { 6 | ...createUtilitiesFromMap( 7 | borderWidth, 8 | (value: string) => ({ 9 | "border-width": value, 10 | }), 11 | "border" 12 | ), 13 | ...createUtilitiesFromMap( 14 | borderWidth, 15 | (value: string) => ({ 16 | "border-top-width": value, 17 | }), 18 | "border-t" 19 | ), 20 | ...createUtilitiesFromMap( 21 | borderWidth, 22 | (value: string) => ({ 23 | "border-right-width": value, 24 | }), 25 | "border-r" 26 | ), 27 | ...createUtilitiesFromMap( 28 | borderWidth, 29 | (value: string) => ({ 30 | "border-bottom-width": value, 31 | }), 32 | "border-b" 33 | ), 34 | ...createUtilitiesFromMap( 35 | borderWidth, 36 | (value: string) => ({ 37 | "border-left-width": value, 38 | }), 39 | "border-l" 40 | ), 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Chad Donohue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/typography/font-size.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Font Size 3 | property: font-size 4 | parent: Typography 5 | route: /typography/font-size 6 | previousRoute: /typography/font-family 7 | previousLabel: Font Family 8 | nextRoute: /typography/font-weight 9 | nextLabel: Font Weight 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box, ConfigConsumer } from "benefit-react" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | import ConfigPropertyList from "../../components/ConfigPropertyList" 17 | import UtilityInfo from "../../components/UtilityInfo" 18 | 19 | 20 | 21 | --- 22 | 23 | 24 | {({ config }) => ( 25 | 26 | {Object.keys(config.theme.fontSize).map((size) => ( 27 | 28 | 29 | The five boxing wizards jump quickly. 30 | 31 | 32 | ))} 33 | 34 | )} 35 | 36 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/image.js: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { useStaticQuery, graphql } from "gatsby" 3 | import Img from "gatsby-image" 4 | 5 | /* 6 | * This component is built using `gatsby-image` to automatically serve optimized 7 | * images with lazy loading and reduced file sizes. The image is loaded using a 8 | * `useStaticQuery`, which allows us to load the image from directly within this 9 | * component, rather than having to pass the image data down from pages. 10 | * 11 | * For more information, see the docs: 12 | * - `gatsby-image`: https://gatsby.dev/gatsby-image 13 | * - `useStaticQuery`: https://www.gatsbyjs.org/docs/use-static-query/ 14 | */ 15 | 16 | const Image = () => { 17 | const data = useStaticQuery(graphql` 18 | query { 19 | placeholderImage: file(relativePath: { eq: "gatsby-astronaut.png" }) { 20 | childImageSharp { 21 | fluid(maxWidth: 300) { 22 | ...GatsbyImageSharpFluid 23 | } 24 | } 25 | } 26 | } 27 | `) 28 | 29 | return 30 | } 31 | 32 | export default Image 33 | -------------------------------------------------------------------------------- /packages/benefit/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Chad Donohue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/benefit-react/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Chad Donohue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/benefit-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "benefit-react", 3 | "version": "2.2.2", 4 | "main": "dist/index.js", 5 | "module": "dist/benefit-react.esm.js", 6 | "types": "dist/index.d.ts", 7 | "repository": "https://github.com/cdonohue/benefit.git", 8 | "contributors": [ 9 | "Chad Donohue ", 10 | "Eric Clemmons " 11 | ], 12 | "description": "Utility CSS library that provides a set of low-level, configurable, ready-to-use styles.", 13 | "license": "MIT", 14 | "keywords": [ 15 | "atomic", 16 | "css", 17 | "css-in-js", 18 | "design", 19 | "emotion", 20 | "jsx", 21 | "system", 22 | "tailwind", 23 | "tailwindcss", 24 | "utility-classes" 25 | ], 26 | "files": [ 27 | "dist" 28 | ], 29 | "peerDependencies": { 30 | "react": ">=16.3.0" 31 | }, 32 | "devDependencies": { 33 | "benefit": "2.2.1" 34 | }, 35 | "scripts": { 36 | "prebuild": "rimraf dist", 37 | "build": "node ../../scripts/build benefit-react", 38 | "prerelease": "yarn build", 39 | "release": "np --tag=benefit-react" 40 | }, 41 | "sideEffects": false 42 | } 43 | -------------------------------------------------------------------------------- /examples/with-next/pages/_app.js: -------------------------------------------------------------------------------- 1 | import App, { Container } from "next/app" 2 | import { react } from "../../../dist/benefit.esm" 3 | 4 | const { ConfigProvider, jsx } = react 5 | 6 | export default class MyApp extends App { 7 | static async getInitialProps({ Component, ctx }) { 8 | let pageProps = {} 9 | 10 | if (Component.getInitialProps) { 11 | pageProps = await Component.getInitialProps(ctx) 12 | } 13 | 14 | return { 15 | pageProps: { ...pageProps, primaryColor: (ctx.query.primary = "#00f") }, 16 | } 17 | } 18 | 19 | render() { 20 | const { Component, pageProps } = this.props 21 | const { primaryColor } = pageProps 22 | return ( 23 | 24 | ({ 26 | ...config, 27 | theme: { 28 | ...config.theme, 29 | textColor: { 30 | ...config.theme.textColor, 31 | primary: primaryColor, 32 | }, 33 | }, 34 | })} 35 | > 36 | 37 | 38 | 39 | ) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/typography/font-weight.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Font Weight 3 | property: font-weight 4 | parent: Typography 5 | route: /typography/font-weight 6 | previousRoute: /typography/font-size 7 | previousLabel: Font Size 8 | nextRoute: /typography/letter-spacing 9 | nextLabel: Letter Spacing 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box, ConfigConsumer } from "benefit-react" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | import ConfigPropertyList from "../../components/ConfigPropertyList" 17 | 18 | import UtilityInfo from "../../components/UtilityInfo" 19 | 20 | 21 | 22 | --- 23 | 24 | 25 | {({ config }) => ( 26 | 27 | {Object.keys(config.theme.fontWeight).map((weight) => ( 28 | 29 | 30 | Pack my box with five dozen liquor jugs. 31 | 32 | 33 | ))} 34 | 35 | )} 36 | 37 | -------------------------------------------------------------------------------- /packages/benefit-docs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 gatsbyjs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /packages/benefit/util/createHash.ts: -------------------------------------------------------------------------------- 1 | export default function createHash(str: string) { 2 | const n = 0x5bd1e995 3 | 4 | let l = str.length, 5 | h = l ^ l, 6 | i = 0, 7 | k 8 | 9 | while (l >= 4) { 10 | k = 11 | (str.charCodeAt(i) & 0xff) | 12 | ((str.charCodeAt(++i) & 0xff) << 8) | 13 | ((str.charCodeAt(++i) & 0xff) << 16) | 14 | ((str.charCodeAt(++i) & 0xff) << 24) 15 | 16 | k = (k & 0xffff) * n + ((((k >>> 16) * n) & 0xffff) << 16) 17 | k ^= k >>> 24 18 | k = (k & 0xffff) * n + ((((k >>> 16) * n) & 0xffff) << 16) 19 | 20 | h = ((h & 0xffff) * n + ((((h >>> 16) * n) & 0xffff) << 16)) ^ k 21 | 22 | l -= 4 23 | ++i 24 | } 25 | 26 | switch (l) { 27 | case 3: 28 | h ^= (str.charCodeAt(i + 2) & 0xff) << 16 29 | case 2: 30 | h ^= (str.charCodeAt(i + 1) & 0xff) << 8 31 | case 1: 32 | h ^= str.charCodeAt(i) & 0xff 33 | h = 34 | (h & 0xffff) * 0x5bd1e995 + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16) 35 | } 36 | 37 | h ^= h >>> 13 38 | h = (h & 0xffff) * n + ((((h >>> 16) * n) & 0xffff) << 16) 39 | h ^= h >>> 15 40 | 41 | return (h >>> 0).toString(36) 42 | } 43 | -------------------------------------------------------------------------------- /packages/benefit/util/initializeContainers.ts: -------------------------------------------------------------------------------- 1 | import isBrowser from "./isBrowser" 2 | 3 | function getMainContainer() { 4 | const container = document.getElementById("benefit-container") 5 | if (container) { 6 | return container 7 | } 8 | 9 | const benefitContainer = document.createElement("div") 10 | benefitContainer.setAttribute("id", "benefit-container") 11 | document.body.insertBefore(benefitContainer, document.body.firstChild) 12 | 13 | return benefitContainer 14 | } 15 | 16 | function initializeContainer(label: string) { 17 | const name = `benefit-${label}` 18 | const container = document.getElementById(name) 19 | if (!container) { 20 | const newContainer = document.createElement("div") 21 | newContainer.setAttribute("id", name) 22 | getMainContainer().appendChild(newContainer) 23 | } 24 | } 25 | 26 | export default function initializeContainers(): void { 27 | if (isBrowser()) { 28 | initializeContainer("preflight") 29 | initializeContainer("global") 30 | initializeContainer("keyframes") 31 | initializeContainer("normalize") 32 | initializeContainer("utilities") 33 | initializeContainer("css") 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/customization/theme.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Theme 3 | route: /customization/theme 4 | parent: Customization 5 | previousRoute: /customization/overview 6 | previousLabel: Customization 7 | nextRoute: /customization/normalize 8 | nextLabel: Normalize 9 | --- 10 | 11 | The `theme` key is a way of holding all of your design system rules to iterate over with any `utilities` defined later. For example, one of the keys in the default `theme` is `fontWeight`: 12 | 13 | ```js 14 | import { ConfigProvider, jsx } from "benefit" 15 | 16 | return ( 17 | { 19 | return { 20 | theme: { 21 | fontWeight: { 22 | hairline: 100, 23 | thin: 200, 24 | light: 300, 25 | normal: 400, 26 | medium: 500, 27 | semibold: 600, 28 | bold: 700, 29 | extrabold: 800, 30 | black: 900, 31 | }, 32 | }, 33 | } 34 | }} 35 | > 36 |
...
37 |
38 | ) 39 | ``` 40 | 41 | You would then be able to iterate over these keys to generate utility classes like `font-hairline`, `font-thin`, etc. 42 | -------------------------------------------------------------------------------- /packages/benefit-react/README.md: -------------------------------------------------------------------------------- 1 | ## Installation 2 | 3 | ```bash 4 | yarn add benefit-react 5 | ``` 6 | 7 | ## Setup transpilation 8 | 9 | Set the jsx pragma at the top of your source file where you intend to use `benefit-react`. 10 | 11 | > Similar to a comment containing linter configuration, this configures the jsx babel plugin to use the `jsx` function instead of `React.createElement`. 12 | > 13 | > [JSX Pragma Documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#pragma) 14 | 15 | Import the `jsx` function from `benefit-react` 16 | 17 | ```js 18 | /** @jsx jsx */ 19 | import { jsx } from "benefit-react" 20 | ``` 21 | 22 | Now, you're free to use any available [utility classes](https://benefit.netlify.com) to style your components 23 | 24 | ```js 25 | /** @jsx jsx */ 26 | import { jsx } from "benefit-react" 27 | 28 | function MyComponent() { 29 | return ( 30 |
31 |

32 | Williamsburg stumptown iPhone, gastropub vegan banh mi 33 | microdosingpost-ironic pok pok +1 bespoke dreamcatcher bushwick brunch. 34 |

35 |
36 | ) 37 | } 38 | ``` 39 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/customization/theme.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Theme 3 | route: /customization/theme/ 4 | parent: Customization 5 | previousRoute: /customization/overview/ 6 | previousLabel: Customization 7 | nextRoute: /customization/utilities/ 8 | nextLabel: Utilities 9 | --- 10 | 11 | The `theme` key is a way of holding all of your design system rules to iterate over with any `utilities` defined later. For example, one of the keys in the default `theme` is `fontWeight`: 12 | 13 | ```js 14 | import { ConfigProvider, jsx } from "benefit" 15 | 16 | return ( 17 | { 19 | return { 20 | theme: { 21 | fontWeight: { 22 | hairline: 100, 23 | thin: 200, 24 | light: 300, 25 | normal: 400, 26 | medium: 500, 27 | semibold: 600, 28 | bold: 700, 29 | extrabold: 800, 30 | black: 900, 31 | }, 32 | }, 33 | } 34 | }} 35 | > 36 |
...
37 |
38 | ) 39 | ``` 40 | 41 | You would then be able to iterate over these keys to generate utility classes like `font-hairline`, `font-thin`, etc. 42 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/typography/letter-spacing.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Letter Spacing 3 | property: letter-spacing 4 | parent: Typography 5 | route: /typography/letter-spacing 6 | previousRoute: /typography/font-weight 7 | previousLabel: Font Weight 8 | nextRoute: /typography/line-height 9 | nextLabel: Line Height 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box, ConfigConsumer } from "benefit-react" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | import ConfigPropertyList from "../../components/ConfigPropertyList" 17 | import UtilityInfo from "../../components/UtilityInfo" 18 | 19 | 20 | 21 | --- 22 | 23 | 24 | {({ config }) => ( 25 | 26 | {Object.keys(config.theme.letterSpacing).map((size) => ( 27 | 28 | 29 | Pack my box with five dozen liquor jugs. 30 | 31 | 32 | ))} 33 | 34 | )} 35 | 36 | -------------------------------------------------------------------------------- /packages/benefit-react/Box.tsx: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { ConfigConsumer } from "./ConfigContext" 3 | 4 | const Box = React.forwardRef( 5 | ( 6 | props: { 7 | children: React.ReactNode[] 8 | className: string 9 | css: any 10 | important: boolean 11 | is: string | React.ComponentClass 12 | }, 13 | ref: React.Ref 14 | ) => { 15 | const { 16 | children, 17 | className = "", 18 | css = "", 19 | important = false, 20 | is = "div", 21 | ...remainingProps 22 | } = props 23 | 24 | const forwardedProps: { 25 | ref?: React.Ref 26 | className?: string 27 | key?: string 28 | } = remainingProps 29 | 30 | forwardedProps.ref = ref 31 | 32 | return ( 33 | 34 | {({ styleWith }) => { 35 | if (className || css) { 36 | forwardedProps.className = styleWith( 37 | `${className} ${css}`, 38 | important 39 | ) 40 | } 41 | 42 | return React.createElement(is, forwardedProps, children) 43 | }} 44 | 45 | ) 46 | } 47 | ) 48 | 49 | export default Box 50 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/interactivity/user-select.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: User Select 3 | property: user-select 4 | parent: Interactivity 5 | route: /interactivity/user-select/ 6 | previousRoute: /interactivity/resize/ 7 | previousLabel: Resize 8 | nextRoute: /svg/fill/ 9 | nextLabel: Fill 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | You should be able to select this text. 20 | 21 | 22 | 23 | 24 | You should be able to select this text. 25 | 26 | 27 | 28 | 29 | You can try but you can't select this text! 30 | 31 | 32 | 33 | 34 | You should be able to select this text. 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/flexbox/display.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flex Display 3 | property: display 4 | parent: Flexbox 5 | route: /flexbox/flex-display/ 6 | previousRoute: /flexbox/flex-direction/ 7 | previousLabel: Flex Direction 8 | nextRoute: /flexbox/flex-grow/ 9 | nextLabel: Flex Grow 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | {[1, 2, 3].map(item => ( 20 | 24 | {item} 25 | 26 | ))} 27 | 28 | 29 | 30 | 31 | {[1, 2, 3].map(item => ( 32 | 36 | {item} 37 | 38 | ))} 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/layout/container.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Container 3 | property: max-width 4 | parent: Layout 5 | route: /layout/container 6 | previousRoute: /utilities 7 | previousLabel: Utilities 8 | nextRoute: /layout/display 9 | nextLabel: Display 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box } from "benefit-react" 14 | import ConfigPropertyList from "../../components/ConfigPropertyList" 15 | import Grid from "../../components/Grid" 16 | import InfoBox from "../../components/InfoBox" 17 | import UtilityInfo from "../../components/UtilityInfo" 18 | 19 | 20 | 21 | --- 22 | 23 | Containers provide a nice, responsive way to wrap your content. Add a `container` class to make an element's `max-width` match the `min-width` of the current breakpoint. All containers have a `width: 100%` applied. 24 | 25 | ```js 26 |
27 |

28 | Business at the speed of light. 29 |

30 |
31 | ``` 32 | 33 | > The above `container` has a utility of `mx-auto` added so it is centered horizontally within the parent. 34 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/UtilityBox.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { useMenus, Link } from "docz" 3 | import { css } from "emotion" 4 | import { jsx } from "benefit-react" 5 | 6 | import Icon from "./Icons" 7 | import Grid from "./Grid" 8 | 9 | const styledLink = css` 10 | transition: 0.1s ease-in-out; 11 | ` 12 | 13 | export default function UtilityBox({ category, icon }) { 14 | const menuItems = useMenus() 15 | 16 | return ( 17 |
18 |
19 |

{category}

20 |
21 |
22 | {menuItems 23 | .filter((item) => item.parent === category) 24 | .map((item) => ( 25 | 30 | {item.name} 31 | 32 | ))} 33 |
34 |
35 | ) 36 | } 37 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/UtilityBox.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { useMenus, Link } from "docz" 3 | import { css } from "emotion" 4 | import { jsx } from "benefit-react" 5 | 6 | import Icon from "./Icons" 7 | import Grid from "./Grid" 8 | 9 | const styledLink = css` 10 | transition: 0.1s ease-in-out; 11 | ` 12 | 13 | export default function UtilityBox({ category, icon }) { 14 | const menuItems = useMenus() 15 | 16 | return ( 17 |
18 |
19 |

{category}

20 |
21 |
22 | {menuItems 23 | .filter((item) => item.parent === category) 24 | .map((item) => ( 25 | 30 | {item.name} 31 | 32 | ))} 33 |
34 |
35 | ) 36 | } 37 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/effects/opacity.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Opacity 3 | property: opacity 4 | parent: Effects 5 | route: /effects/opacity 6 | previousRoute: /effects/box-shadow 7 | previousLabel: Box Shadow 8 | nextRoute: /interactivity/appearance 9 | nextLabel: Appearance 10 | --- 11 | 12 | import { Box, ConfigConsumer } from "benefit-react" 13 | import Grid from "../../components/Grid" 14 | import InfoBox from "../../components/InfoBox" 15 | import ConfigPropertyList from "../../components/ConfigPropertyList" 16 | import UtilityInfo from "../../components/UtilityInfo" 17 | 18 | 19 | 20 | --- 21 | 22 | 23 | 24 | opacity-100 25 | 26 | 27 | opacity-75 28 | 29 | 30 | opacity-50 31 | 32 | 33 | opacity-25 34 | 35 | 36 | opacity-0 37 | 38 | 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # docz files 58 | .docz 59 | 60 | # Mac files 61 | .DS_Store 62 | 63 | # Yarn 64 | yarn-error.log 65 | .pnp/ 66 | .pnp.js 67 | # Yarn Integrity file 68 | .yarn-integrity 69 | 70 | dist 71 | build 72 | .next -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/border/border-style.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Border Style 3 | property: border-style 4 | parent: Border 5 | route: /border/border-style 6 | previousRoute: /border/border-radius 7 | previousLabel: Border Radius 8 | nextRoute: /border/border-width 9 | nextLabel: Border Width 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import ConfigPropertyList from "../../components/ConfigPropertyList" 14 | import Grid from "../../components/Grid" 15 | import InfoBox from "../../components/InfoBox" 16 | import { Box, ConfigConsumer } from "benefit-react" 17 | import UtilityInfo from "../../components/UtilityInfo" 18 | 19 | 20 | 21 | --- 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/svg/stroke.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Stroke 3 | property: stroke 4 | parent: Svg 5 | route: /svg/stroke 6 | previousRoute: /svg/fill 7 | previousLabel: Fill 8 | --- 9 | 10 | import Icon from "../../components/Icons" 11 | import InfoBox from "../../components/InfoBox" 12 | import Grid from "../../components/Grid" 13 | import UtilityInfo from "../../components/UtilityInfo" 14 | import { Box } from "benefit-react" 15 | 16 | 17 | 18 | --- 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /packages/benefit-docs/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # gatsby files 58 | .cache/ 59 | public 60 | 61 | # Mac files 62 | .DS_Store 63 | 64 | # Yarn 65 | yarn-error.log 66 | .pnp/ 67 | .pnp.js 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/typography/line-height.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Line Height 3 | property: line-height 4 | parent: Typography 5 | route: /typography/line-height 6 | previousRoute: /typography/letter-spacing 7 | previousLabel: Letter Spacing 8 | nextRoute: /typography/lists 9 | nextLabel: Lists 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box, ConfigConsumer } from "benefit-react" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | import ConfigPropertyList from "../../components/ConfigPropertyList" 17 | 18 | import UtilityInfo from "../../components/UtilityInfo" 19 | 20 | 21 | 22 | --- 23 | 24 | 25 | {({ config }) => ( 26 | 27 | {Object.keys(config.theme.lineHeight).map((size) => ( 28 | 29 | 30 | Portland flannel trust fund plaid kitsch. Hot chicken everyday carry williamsburg YOLO green juice lomo. Bicycle rights man bun +1 shabby chic migas salvia listicle polaroid paleo. 31 | 32 | 33 | ))} 34 | 35 | 36 | )} 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Utilities 3 | route: /utilities 4 | previousRoute: /how-it-works 5 | previousLabel: How it works 6 | nextRoute: /customization 7 | nextLabel: Customization 8 | --- 9 | 10 | import Grid from "./components/Grid" 11 | import { Box } from "benefit-react" 12 | import Icon from "./components/Icons" 13 | import UtilityBox from "./components/UtilityBox" 14 | 15 | Many utilities ship with `benefit` to reduce the amount of styling you need to add. Browse the built in utilities below and visit any one of them for more detail on what they provide. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Don't see a utility? Continue to read more about customization to learn about how to create your own utilities. 32 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/color.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Color 3 | route: /color 4 | previousRoute: /how-it-works 5 | previousLabel: How It Works 6 | nextRoute: /utilities 7 | nextLabel: Utilities 8 | --- 9 | 10 | import ColorSwatch from "./components/ColorSwatch" 11 | import Grid from "./components/Grid" 12 | 13 | `benefit` ships with default color palettes. These colors are used by the default theme and are available to use when creating your own customizations. The naming pattern for each color ranges from 100 to 900 (lightest to darkest). 14 | 15 | In the default configuration, these colors are used to generate the [Text Color](/typography/text-color), [Background Color](background/background-color), and [Border Color](border/border-color) utilities. 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | There is also a set of `gray` colors, along with `black` and `white` 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/svg/fill.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Fill 3 | property: fill 4 | parent: Svg 5 | route: /svg/fill 6 | previousRoute: /interactivity/user-select 7 | previousLabel: User Select 8 | nextRoute: /svg/stroke 9 | nextLabel: Stroke 10 | --- 11 | 12 | import Icon from "../../components/Icons" 13 | import InfoBox from "../../components/InfoBox" 14 | import Grid from "../../components/Grid" 15 | import UtilityInfo from "../../components/UtilityInfo" 16 | import { Box } from "benefit-react" 17 | 18 | 19 | 20 | --- 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/customization/normalize.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Normalize 3 | route: /customization/normalize 4 | parent: Customization 5 | previousRoute: /customization/theme 6 | previousLabel: Theme 7 | nextRoute: /customization/utilities 8 | nextLabel: Utilities 9 | --- 10 | 11 | The `normalize` key is your hook to provide any base css to be applied before any utility classes are parsed and applied. Supply a function here that returns your normalized styles as an object. 12 | 13 | We'll use the defaults as an example here to showcase using the defined `theme` values to help you apply any normalize styles: 14 | 15 | ```js 16 | function myConfig(config) { 17 | return { 18 | ...config, 19 | normalize: (theme) => { 20 | return { 21 | margin: "0", 22 | padding: "0", 23 | "border-width": "0", 24 | "border-style": "solid", 25 | "border-color": theme.borderColor.default, 26 | color: "inherit", 27 | "font-family": "inherit", 28 | "font-size": "inherit", 29 | "font-weight": "inherit", 30 | "line-height": "inherit", 31 | "vertical-align": "baseline", 32 | "box-sizing": "border-box", 33 | } 34 | }, 35 | } 36 | } 37 | ``` 38 | 39 | ```js 40 | const { styleWith } = benefit(myConfig) 41 | ``` 42 | 43 | or 44 | 45 | ```js 46 | 47 | ``` 48 | -------------------------------------------------------------------------------- /packages/benefit-docs/gatsby-node.js: -------------------------------------------------------------------------------- 1 | const path = require("path") 2 | 3 | exports.createPages = async ({ graphql, actions, reporter }) => { 4 | // Destructure the createPage function from the actions object 5 | const { createPage } = actions 6 | const result = await graphql(` 7 | query { 8 | allMdx { 9 | edges { 10 | node { 11 | id 12 | frontmatter { 13 | route 14 | } 15 | } 16 | } 17 | } 18 | } 19 | `) 20 | if (result.errors) { 21 | reporter.panic('🚨 ERROR: Loading "createPages" query', result.errors) 22 | } 23 | // Create blog post pages. 24 | const docs = result.data.allMdx.edges 25 | // We'll call `createPage` for each result 26 | docs.forEach(({ node }, index) => { 27 | createPage({ 28 | // This is the slug we created before 29 | // (or `node.frontmatter.slug`) 30 | path: node.frontmatter.route, 31 | // This component will wrap our MDX content 32 | component: path.resolve(`./src/components/Page.js`), 33 | // We can use the values in this context in 34 | // our page layout component 35 | context: { id: node.id }, 36 | }) 37 | }) 38 | } 39 | 40 | exports.onCreateWebpackConfig = ({ actions }) => { 41 | actions.setWebpackConfig({ 42 | node: { 43 | fs: "empty", 44 | }, 45 | }) 46 | } 47 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/customization/normalize.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Normalize 3 | route: /customization/normalize/ 4 | parent: Customization 5 | previousRoute: /customization/theme/ 6 | previousLabel: Theme 7 | nextRoute: /customization/utilities/ 8 | nextLabel: Utilities 9 | --- 10 | 11 | The `normalize` key is your hook to provide any base css to be applied before any utility classes are parsed and applied. Supply a function here that returns your normalized styles as an object. 12 | 13 | We'll use the defaults as an example here to showcase using the defined `theme` values to help you apply any normalize styles: 14 | 15 | ```js 16 | function myConfig(config) { 17 | return { 18 | ...config, 19 | normalize: theme => { 20 | return { 21 | margin: "0", 22 | padding: "0", 23 | "border-width": "0", 24 | "border-style": "solid", 25 | "border-color": theme.borderColor.default, 26 | color: "inherit", 27 | "font-family": "inherit", 28 | "font-size": "inherit", 29 | "font-weight": "inherit", 30 | "line-height": "inherit", 31 | "vertical-align": "baseline", 32 | "box-sizing": "border-box", 33 | } 34 | }, 35 | } 36 | } 37 | ``` 38 | 39 | ```js 40 | const { styleWith } = benefit(myConfig) 41 | ``` 42 | 43 | or 44 | 45 | ```js 46 | 47 | ``` 48 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/interactivity/user-select.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: User Select 3 | property: user-select 4 | parent: Interactivity 5 | route: /interactivity/user-select 6 | previousRoute: /interactivity/resize 7 | previousLabel: Resize 8 | nextRoute: /svg/fill 9 | nextLabel: Fill 10 | --- 11 | 12 | import { Box } from "benefit-react" 13 | import UtilityInfo from "../../components/UtilityInfo" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | 17 | 18 | 19 | --- 20 | 21 | 22 | 23 | 24 | You should be able to select this text. 25 | 26 | 27 | 28 | 29 | You should be able to select this text. 30 | 31 | 32 | 33 | 34 | You can try but you can't select this text! 35 | 36 | 37 | 38 | 39 | You should be able to select this text. 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/flexbox/display.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flex Display 3 | property: display 4 | parent: Flexbox 5 | route: /flexbox/flex-display 6 | previousRoute: /flexbox/flex-direction 7 | previousLabel: Flex Direction 8 | nextRoute: /flexbox/flex-grow 9 | nextLabel: Flex Grow 10 | --- 11 | 12 | import { Box } from "benefit-react" 13 | import InfoBox from "../../components/InfoBox" 14 | import Grid from "../../components/Grid" 15 | 16 | import UtilityInfo from "../../components/UtilityInfo" 17 | 18 | 19 | 20 | --- 21 | 22 | 23 | 24 | 25 | {[1, 2, 3].map((item) => ( 26 | 30 | {item} 31 | 32 | ))} 33 | 34 | 35 | 36 | 37 | {[1, 2, 3].map((item) => ( 38 | 42 | {item} 43 | 44 | ))} 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/inset.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { inset = {} } = theme 5 | return { 6 | ...createUtilitiesFromMap( 7 | inset, 8 | (value: string) => ({ 9 | top: value, 10 | right: value, 11 | bottom: value, 12 | left: value, 13 | }), 14 | "inset" 15 | ), 16 | ...createUtilitiesFromMap( 17 | inset, 18 | (value: string) => ({ 19 | right: value, 20 | left: value, 21 | }), 22 | "inset-x" 23 | ), 24 | ...createUtilitiesFromMap( 25 | inset, 26 | (value: string) => ({ 27 | top: value, 28 | bottom: value, 29 | }), 30 | "inset-y" 31 | ), 32 | ...createUtilitiesFromMap( 33 | inset, 34 | (value: string) => ({ 35 | top: value, 36 | }), 37 | "top" 38 | ), 39 | ...createUtilitiesFromMap( 40 | inset, 41 | (value: string) => ({ 42 | right: value, 43 | }), 44 | "right" 45 | ), 46 | ...createUtilitiesFromMap( 47 | inset, 48 | (value: string) => ({ 49 | bottom: value, 50 | }), 51 | "bottom" 52 | ), 53 | ...createUtilitiesFromMap( 54 | inset, 55 | (value: string) => ({ 56 | left: value, 57 | }), 58 | "left" 59 | ), 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/padding.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { padding = {} } = theme 5 | return { 6 | ...createUtilitiesFromMap( 7 | padding, 8 | (value: string) => ({ 9 | padding: value, 10 | }), 11 | "p" 12 | ), 13 | ...createUtilitiesFromMap( 14 | padding, 15 | (value: string) => ({ 16 | "padding-left": value, 17 | "padding-right": value, 18 | }), 19 | "px" 20 | ), 21 | ...createUtilitiesFromMap( 22 | padding, 23 | (value: string) => ({ 24 | "padding-top": value, 25 | "padding-bottom": value, 26 | }), 27 | "py" 28 | ), 29 | ...createUtilitiesFromMap( 30 | padding, 31 | (value: string) => ({ 32 | "padding-top": value, 33 | }), 34 | "pt" 35 | ), 36 | ...createUtilitiesFromMap( 37 | padding, 38 | (value: string) => ({ 39 | "padding-right": value, 40 | }), 41 | "pr" 42 | ), 43 | ...createUtilitiesFromMap( 44 | padding, 45 | (value: string) => ({ 46 | "padding-bottom": value, 47 | }), 48 | "pb" 49 | ), 50 | ...createUtilitiesFromMap( 51 | padding, 52 | (value: string) => ({ 53 | "padding-left": value, 54 | }), 55 | "pl" 56 | ), 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/benefit/config/utilities/position.ts: -------------------------------------------------------------------------------- 1 | import createUtilitiesFromMap from "../createUtilitiesFromMap" 2 | 3 | export default function generate(theme: any) { 4 | const { inset } = theme 5 | 6 | return { 7 | static: { position: "static" }, 8 | fixed: { position: "fixed" }, 9 | absolute: { position: "absolute" }, 10 | relative: { position: "relative" }, 11 | sticky: { position: "sticky" }, 12 | ...createUtilitiesFromMap( 13 | inset, 14 | (value: string) => ({ 15 | top: value, 16 | right: value, 17 | bottom: value, 18 | left: value, 19 | }), 20 | "inset" 21 | ), 22 | ...createUtilitiesFromMap( 23 | inset, 24 | (value: string) => ({ right: value, left: value }), 25 | "inset-x" 26 | ), 27 | ...createUtilitiesFromMap( 28 | inset, 29 | (value: string) => ({ top: value, bottom: value }), 30 | "inset-y" 31 | ), 32 | ...createUtilitiesFromMap( 33 | inset, 34 | (value: string) => ({ top: value }), 35 | "top" 36 | ), 37 | ...createUtilitiesFromMap( 38 | inset, 39 | (value: string) => ({ right: value }), 40 | "right" 41 | ), 42 | ...createUtilitiesFromMap( 43 | inset, 44 | (value: string) => ({ bottom: value }), 45 | "bottom" 46 | ), 47 | ...createUtilitiesFromMap( 48 | inset, 49 | (value: string) => ({ left: value }), 50 | "left" 51 | ), 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/benefit-docs/gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: `Gatsby Default Starter`, 4 | description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, 5 | author: `@gatsbyjs`, 6 | }, 7 | plugins: [ 8 | `gatsby-plugin-react-helmet`, 9 | { 10 | resolve: `gatsby-source-filesystem`, 11 | options: { 12 | name: `images`, 13 | path: `${__dirname}/src/images`, 14 | }, 15 | }, 16 | `gatsby-transformer-sharp`, 17 | `gatsby-plugin-sharp`, 18 | { 19 | resolve: `gatsby-plugin-manifest`, 20 | options: { 21 | name: `gatsby-starter-default`, 22 | short_name: `starter`, 23 | start_url: `/`, 24 | background_color: `#663399`, 25 | theme_color: `#663399`, 26 | display: `minimal-ui`, 27 | icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. 28 | }, 29 | }, 30 | "gatsby-plugin-mdx", 31 | { 32 | resolve: "gatsby-source-filesystem", 33 | options: { 34 | name: "docs", 35 | path: `${__dirname}/src/docs/`, 36 | }, 37 | }, 38 | `gatsby-plugin-typescript`, 39 | // this (optional) plugin enables Progressive Web App + Offline functionality 40 | // To learn more, visit: https://gatsby.dev/offline 41 | // `gatsby-plugin-offline`, 42 | ], 43 | } 44 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/interactivity/resize.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Resize 3 | property: resize 4 | parent: Interactivity 5 | route: /interactivity/resize/ 6 | previousRoute: /interactivity/pointer-events/ 7 | previousLabel: Pointer Events 8 | nextRoute: /interactivity/user-select/ 9 | nextLabel: User Select 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | For any of these `resize` utilities to work, you must apply an [overflow](/layout/overflow) class other than the default `visible` behavior. These example all have `overflow-hidden` applied as an example. 17 | 18 | 19 | 20 | 21 | I can be resized in both directions 22 | 23 | 24 | 25 | 26 | I cannot be resized 27 | 28 | 29 | 30 | 31 | I can be resized horizontally 32 | 33 | 34 | 35 | 36 | I can be resized vertically 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/flexbox/grow.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flex Grow 3 | property: flex-grow 4 | parent: Flexbox 5 | route: /flexbox/flex-grow/ 6 | previousRoute: /flexbox/flex-display/ 7 | previousLabel: Flex Display 8 | nextRoute: /flexbox/flex-shrink/ 9 | nextLabel: Flex Shrink 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | 20 | Will not grow 21 | 22 | 23 | Will grow 24 | 25 | 26 | Will not grow 27 | 28 | 29 | 30 | 31 | 32 | 33 | Will grow 34 | 35 | 36 | Will not grow 37 | 38 | 39 | Will grow 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/background/background-size.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Background Size 3 | property: background-size 4 | parent: Background 5 | route: /background/background-size/ 6 | previousRoute: /background/background-repeat/ 7 | previousLabel: Background Repeat 8 | nextRoute: /border/border-color/ 9 | nextLabel: Border Color 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 25 | 26 | 27 | 34 | 35 | 36 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/typography/text-alignment.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Text Alignment 3 | property: text-align 4 | parent: Typography 5 | route: /typography/text-alignment/ 6 | previousRoute: /typography/style-decoration/ 7 | previousLabel: Style and Decoration 8 | nextRoute: /typography/text-color/ 9 | nextLabel: Text Color 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 20 | aesthetic twee tumeric next level hell of heirloom.{" "} 21 | 22 | 23 | 24 | 25 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 26 | aesthetic twee tumeric next level hell of heirloom.{" "} 27 | 28 | 29 | 30 | 31 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 32 | aesthetic twee tumeric next level hell of heirloom.{" "} 33 | 34 | 35 | 36 | 37 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 38 | aesthetic twee tumeric next level hell of heirloom.{" "} 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /packages/benefit-react/ServerStyleManager.tsx: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { registry } from "benefit" 3 | 4 | function createContainer(label: string, styles: any[]) { 5 | return ( 6 |
7 | {styles.map((s: any) => ( 8 | 19 | ))} 20 |
21 | ) 22 | } 23 | 24 | export default function ServerStyleManager() { 25 | const benefitRegistry = registry.getInstance() 26 | const { 27 | css, 28 | global, 29 | keyframes, 30 | normalize, 31 | preflight, 32 | utilities, 33 | } = benefitRegistry.getRegistry() 34 | 35 | return ( 36 |
37 | 46 | {createContainer("preflight", preflight)} 47 | {createContainer("global", global)} 48 | {createContainer("keyframes", keyframes)} 49 | {createContainer("normalize", normalize)} 50 | {createContainer("utilities", utilities)} 51 | {createContainer("css", css)} 52 |
53 | ) 54 | } 55 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/customization/apply.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Apply 3 | route: /customization/apply/ 4 | parent: Customization 5 | previousRoute: /customization/variants/ 6 | previousLabel: Variants 7 | nextRoute: /layout/container/ 8 | nextLabel: Container 9 | --- 10 | 11 | Once you start noticing patterns of repeated classes in your component/application, you can use the `apply` key to map a more appropriate name to an array of utility classes. 12 | 13 | ```js 14 | import { ConfigProvider, jsx } from "benefit-react" 15 | 16 | return ( 17 | { 19 | return { 20 | ...config, 21 | apply: { 22 | "hero-banner": [ 23 | "p-8", 24 | "text-2xl", 25 | "text-center", 26 | "uppercase", 27 | "bg-blue-500", 28 | "text-white", 29 | "tracking-tight", 30 | ], 31 | }, 32 | } 33 | }} 34 | > 35 |
Business at the speed of light
36 |
37 | ) 38 | ``` 39 | 40 | { 42 | return { 43 | ...config, 44 | apply: { 45 | "hero-banner": [ 46 | "p-8", 47 | "text-2xl", 48 | "text-center", 49 | "uppercase", 50 | "bg-blue-500", 51 | "text-white", 52 | "tracking-tight", 53 | ], 54 | }, 55 | } 56 | }} 57 | > 58 | 59 | Business at the speed of light 60 | 61 | 62 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/effects/box-shadow.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Box Shadow 3 | property: box-shadow 4 | parent: Effects 5 | route: /effects/box-shadow/ 6 | previousRoute: /tables/table-layout/ 7 | previousLabel: Table Layout 8 | nextRoute: /effects/opacity/ 9 | nextLabel: Opacity 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/flexbox/shrink.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flex Shrink 3 | property: flex-shrink 4 | parent: Flexbox 5 | route: /flexbox/flex-shrink/ 6 | previousRoute: /flexbox/flex-grow/ 7 | previousLabel: Flex Grow 8 | nextRoute: /flexbox/flex-wrapping/ 9 | nextLabel: Flex Wrapping 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | 20 | Will not shrink 21 | 22 | 23 | This will shrink, even if it means the content will end up wrapping. 24 | 25 | 26 | Will not shrink 27 | 28 | 29 | 30 | 31 | 32 | 33 | Will shrink 34 | 35 | 36 | Will not shrink below its initial size 37 | 38 | 39 | Will shrink 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/interactivity/pointer-events.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Pointer Events 3 | property: pointer-events 4 | parent: Interactivity 5 | route: /interactivity/pointer-events/ 6 | previousRoute: /interactivity/outline/ 7 | previousLabel: Outline 8 | nextRoute: /interactivity/resize/ 9 | nextLabel: Resize 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | This sets whether or not a particular element can become the target of pointer events. The two examples below attempt to show an alert box on click. Notice how the second button never triggers the alert. 17 | 18 | 19 | 20 | alert("Button clicked")} 24 | className="bg-gray-600 text-white w-full p-4 rounded shadow-lg font-semibold uppercase" 25 | > 26 | A Button 27 | 28 | 29 | 33 | alert("Button clicked")} 37 | className="pointer-events-none bg-gray-600 text-white w-full p-4 rounded shadow-lg font-semibold uppercase" 38 | > 39 | A Button 40 | 41 | 42 | 43 | 44 | > In addition to indicating that the element is not the target of pointer events, the value `none` instructs the pointer event to go "through" the element and target whatever is "underneath" that element instead. 45 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/interactivity/resize.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Resize 3 | property: resize 4 | parent: Interactivity 5 | route: /interactivity/resize 6 | previousRoute: /interactivity/pointer-events 7 | previousLabel: Pointer Events 8 | nextRoute: /interactivity/user-select 9 | nextLabel: User Select 10 | --- 11 | 12 | import { Box } from "benefit-react" 13 | import UtilityInfo from "../../components/UtilityInfo" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | 17 | 18 | 19 | --- 20 | 21 | For any of these `resize` utilities to work, you must apply an [overflow](/layout/overflow) class other than the default `visible` behavior. These example all have `overflow-hidden` applied as an example. 22 | 23 | 24 | 25 | 26 | I can be resized in both directions 27 | 28 | 29 | 30 | 31 | I cannot be resized 32 | 33 | 34 | 35 | 36 | I can be resized horizontally 37 | 38 | 39 | 40 | 41 | I can be resized vertically 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /scripts/css.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const emotion = require("emotion") 4 | const { readFileSync, writeFileSync } = require("fs") 5 | const { resolve } = require("path") 6 | 7 | const benefit = require("../dist/benefit")() 8 | 9 | // normalize.css + Tailwind's preflight for compatability 10 | const base = readFileSync(require.resolve("tailwindcss/dist/base.css"), "utf8") 11 | 12 | // Benefit's utility CSS 13 | const utilities = Object.keys(benefit.utilities) 14 | .map((utility) => { 15 | // Call `styleWith` as if it was being used & extract the non-reset class 16 | // (e.g. `css-1234`) 17 | const emotionclassName = benefit 18 | .styleWith(utility) 19 | .split(" ") 20 | .pop() 21 | 22 | // Remove the `css-` prefix 23 | // (e.g. `1234`) 24 | const [, hash] = emotionclassName.split("-") 25 | 26 | // Get the rule as it would be inserted 27 | // e.g. css-1234:hover{opacity:0;} 28 | const inserted = emotion.cache.inserted[hash] 29 | 30 | // Replae `css-1234` with `hover:opacity-0` 31 | return inserted.replace( 32 | emotionclassName, 33 | utility.replace(":", "\\:").replace("/", "\\/") 34 | ) 35 | }) 36 | .join("\n") 37 | .concat("\n") 38 | 39 | const outputDir = resolve(__dirname, "../dist") 40 | 41 | console.info(`> Output ${resolve(outputDir, "base.css")}`) 42 | writeFileSync(resolve(outputDir, "base.css"), base) 43 | 44 | console.info(`> Output ${resolve(outputDir, "utilities.css")}`) 45 | writeFileSync(resolve(outputDir, "utilities.css"), utilities) 46 | 47 | console.info(`> Output ${resolve(outputDir, "benefit.css")}`) 48 | writeFileSync(resolve(outputDir, "benefit.css"), [base, utilities].join("\n")) 49 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/flexbox/grow.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flex Grow 3 | property: flex-grow 4 | parent: Flexbox 5 | route: /flexbox/flex-grow 6 | previousRoute: /flexbox/flex-display 7 | previousLabel: Flex Display 8 | nextRoute: /flexbox/flex-shrink 9 | nextLabel: Flex Shrink 10 | --- 11 | 12 | import { Box } from "benefit-react" 13 | import InfoBox from "../../components/InfoBox" 14 | import Grid from "../../components/Grid" 15 | import UtilityInfo from "../../components/UtilityInfo" 16 | 17 | 18 | 19 | --- 20 | 21 | 22 | 23 | 24 | 25 | Will not grow 26 | 27 | 28 | Will grow 29 | 30 | 31 | Will not grow 32 | 33 | 34 | 35 | 36 | 37 | 38 | Will grow 39 | 40 | 41 | Will not grow 42 | 43 | 44 | Will grow 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /packages/benefit/util/createCache.ts: -------------------------------------------------------------------------------- 1 | function findInsertionIndex( 2 | index: number, 3 | array: Array<{ index: number }>, 4 | low: number = 0, 5 | high: number = array.length - 1 6 | ): number { 7 | if (!array.length) { 8 | return 0 9 | } 10 | 11 | while (low <= high) { 12 | const mid = low + ((high - low) >> 1) 13 | const value = array[mid].index 14 | 15 | if (index < value) { 16 | high = mid - 1 17 | } else if (index > value) { 18 | low = mid + 1 19 | } else { 20 | return mid 21 | } 22 | } 23 | 24 | return low 25 | } 26 | 27 | function insertUtility( 28 | insertAtIndex: number, 29 | newUtility: any, 30 | utilities: any[] 31 | ) { 32 | let newUtilities 33 | 34 | if (insertAtIndex <= 0) { 35 | newUtilities = [newUtility, ...utilities] 36 | } else if (insertAtIndex >= utilities.length) { 37 | newUtilities = [...utilities, newUtility] 38 | } else { 39 | newUtilities = [ 40 | ...utilities.slice(0, insertAtIndex), 41 | newUtility, 42 | ...utilities.slice(insertAtIndex), 43 | ] 44 | } 45 | 46 | return newUtilities 47 | } 48 | 49 | export default function createCache(initialUtilities: any = []) { 50 | let utilities: any = [].concat(initialUtilities) 51 | 52 | return { 53 | addUtility(utility: { id: string; index: number }) { 54 | if (!utilities.map((u: any) => u.id).includes(utility.id)) { 55 | const newIndex = findInsertionIndex(utility.index, utilities) 56 | utilities = insertUtility(newIndex, utility, utilities) 57 | return newIndex 58 | } 59 | 60 | return -1 61 | }, 62 | getUtilities() { 63 | return utilities 64 | }, 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import pkg from "./package.json" 2 | import typescript from "rollup-plugin-typescript2" 3 | import resolve from "rollup-plugin-node-resolve" 4 | import commonjs from "rollup-plugin-commonjs" 5 | import replace from "rollup-plugin-replace" 6 | import { terser } from "rollup-plugin-terser" 7 | 8 | const outputOptions = { 9 | sourcemap: true, 10 | freeze: false, 11 | esModule: false, 12 | treeshake: { 13 | propertyReadSideEffects: false, 14 | }, 15 | name: pkg.name, 16 | globals: { react: "React", "react-native": "ReactNative" }, 17 | } 18 | 19 | export default { 20 | input: "./src/index.ts", 21 | output: [ 22 | { 23 | file: pkg.main, 24 | format: "cjs", 25 | ...outputOptions, 26 | }, 27 | { 28 | file: pkg["umd:main"], 29 | format: "umd", 30 | ...outputOptions, 31 | }, 32 | { 33 | file: pkg.module, 34 | format: "esm", 35 | ...outputOptions, 36 | }, 37 | ], 38 | plugins: [ 39 | typescript({ 40 | typescript: require("typescript"), 41 | }), 42 | resolve(), 43 | commonjs(), 44 | replace({ 45 | //enable find-replacing variable in JS code to use ENV varibale for conditional code 46 | ENV: JSON.stringify(process.env.NODE_ENV || "development"), // key = var name, value = replace 47 | }), 48 | process.env.NODE_ENV === "production" && 49 | terser({ 50 | sourcemap: true, 51 | output: { comments: false }, 52 | compress: { 53 | keep_infinity: true, 54 | pure_getters: true, 55 | passes: 10, 56 | }, 57 | ecma: 5, 58 | toplevel: format === "cjs", 59 | warnings: true, 60 | }), 61 | ], 62 | } 63 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/components/Color.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import polychrome from "polychrome" 3 | import { jsx } from "benefit-react" 4 | 5 | export default function Color({ className, name, colors }) { 6 | if (name === "default") return
7 | 8 | const isSingleColor = typeof colors === "string" 9 | let baseColor = isSingleColor ? colors : colors[400] 10 | let isTransparent = false 11 | 12 | if (isSingleColor && baseColor === "transparent") { 13 | baseColor = "#fff" 14 | isTransparent = true 15 | } 16 | 17 | const baseContrast = polychrome(baseColor) 18 | .contrast() 19 | .hex() 20 | return ( 21 |
24 |
33 | {name} 34 | {!isSingleColor && "-{level}"} 35 |
36 | {!isSingleColor && ( 37 |
38 | {Object.keys(colors).map(shade => { 39 | const shadeContrast = polychrome(colors[shade]) 40 | .contrast() 41 | .hex() 42 | return ( 43 |
47 | ) 48 | })} 49 |
50 | )} 51 |
52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/introduction.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Introduction 3 | route: / 4 | nextRoute: /installation/agnostic/ 5 | nextLabel: Installation 6 | showLogo: true 7 | --- 8 | 9 | > `benefit` is a utility CSS-in-JS library that provides a set of low-level, configurable, ready-to-use styles. These styles are generated for you as you use them, so you don't have to worry about including stylesheets or eliminating unused styles. 10 | 11 | ### Let's look at a quick example: 12 | 13 | Here, we are applying 5 utility classes to a `
`. Click any class to remove it and try adding some new ones (like `bg-pink-400` or `italic`). 14 | 15 | --- 16 | 17 | 20 | 21 | As the class names are interpreted, style rules are inserted into your markup and cached for another element to take advantage of. This way, any utility only gets inserted once. 22 | 23 | ### Now, we'll start from scratch 24 | 25 | Let's start off with an unstyled `
` with some alert content. The goal is for us to make this look like an error that is displayed to the user. 26 | 27 | - First, we'll add `bg-red-800` to style the background 28 | - Next, add `text-white` 29 | - Add some padding with `p-4` 30 | - Round the corners using `rounded` 31 | - Raise the error off of the page a bit by adding `shadow-xl` 32 | 33 | 36 | This is an 37 | alert message 38 | 39 | } 40 | hiddenUtilities={["flex", "items-center"]} 41 | /> 42 | 43 | > Read more about utilities for [Background Color](/background/background-color), [Text Color](), [Padding](), [Border Radius](), and [Box Shadow]() 44 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/customization/apply.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Apply 3 | route: /customization/apply 4 | parent: Customization 5 | previousRoute: /customization/variants 6 | previousLabel: Variants 7 | nextRoute: /layout/container 8 | nextLabel: Container 9 | --- 10 | 11 | import { ConfigProvider, Box } from "benefit-react" 12 | import { 13 | createUtilitiesFromMap, 14 | createVariant, 15 | createVariantsFromMap, 16 | } from "benefit" 17 | 18 | Once you start noticing patterns of repeated classes in your component/application, you can use the `apply` key to map a more appropriate name to an array of utility classes. 19 | 20 | ```js 21 | import { ConfigProvider, jsx } from "benefit" 22 | 23 | return ( 24 | { 26 | return { 27 | ...config, 28 | apply: { 29 | "hero-banner": [ 30 | "p-8", 31 | "text-2xl", 32 | "text-center", 33 | "uppercase", 34 | "bg-blue-500", 35 | "text-white", 36 | "tracking-tight", 37 | ], 38 | }, 39 | } 40 | }} 41 | > 42 |
Business at the speed of light
43 |
44 | ) 45 | ``` 46 | 47 | { 49 | return { 50 | ...config, 51 | apply: { 52 | "hero-banner": [ 53 | "p-8", 54 | "text-2xl", 55 | "text-center", 56 | "uppercase", 57 | "bg-blue-500", 58 | "text-white", 59 | "tracking-tight", 60 | ], 61 | }, 62 | } 63 | }} 64 | > 65 | 66 | Business at the speed of light 67 | 68 | 69 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/background/background-size.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Background Size 3 | property: background-size 4 | parent: Background 5 | route: /background/background-size 6 | previousRoute: /background/background-repeat 7 | previousLabel: Background Repeat 8 | nextRoute: /border/border-color 9 | nextLabel: Border Color 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import InfoBox from "../../components/InfoBox" 14 | import Grid from "../../components/Grid" 15 | import { Box } from "benefit-react" 16 | 17 | import UtilityInfo from "../../components/UtilityInfo" 18 | 19 | 20 | 21 | --- 22 | 23 | 24 | 25 | 32 | 33 | 34 | 41 | 42 | 43 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/components/Color.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import polychrome from "polychrome" 3 | import { jsx } from "benefit-react" 4 | 5 | export default function Color({ className, name, colors }) { 6 | if (name === "default") return
7 | 8 | const isSingleColor = typeof colors === "string" 9 | let baseColor = isSingleColor ? colors : colors[400] 10 | let isTransparent = false 11 | 12 | if (isSingleColor && baseColor === "transparent") { 13 | baseColor = "#fff" 14 | isTransparent = true 15 | } 16 | 17 | const baseContrast = polychrome(baseColor) 18 | .contrast() 19 | .hex() 20 | return ( 21 |
24 |
33 | {name} 34 | {!isSingleColor && "-{level}"} 35 |
36 | {!isSingleColor && ( 37 |
38 | {Object.keys(colors).map((shade) => { 39 | const shadeContrast = polychrome(colors[shade]) 40 | .contrast() 41 | .hex() 42 | return ( 43 |
47 | {shade} 48 |
49 | ) 50 | })} 51 |
52 | )} 53 |
54 | ) 55 | } 56 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/flexbox/shrink.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flex Shrink 3 | property: flex-shrink 4 | parent: Flexbox 5 | route: /flexbox/flex-shrink 6 | previousRoute: /flexbox/flex-grow 7 | previousLabel: Flex Grow 8 | nextRoute: /flexbox/flex-wrapping 9 | nextLabel: Flex Wrapping 10 | --- 11 | 12 | import { Box } from "benefit-react" 13 | import InfoBox from "../../components/InfoBox" 14 | import Grid from "../../components/Grid" 15 | import UtilityInfo from "../../components/UtilityInfo" 16 | 17 | 18 | 19 | --- 20 | 21 | 22 | 23 | 24 | 25 | Will not shrink 26 | 27 | 28 | This will shrink, even if it means the content will end up wrapping. 29 | 30 | 31 | Will not shrink 32 | 33 | 34 | 35 | 36 | 37 | 38 | Will shrink 39 | 40 | 41 | Will not shrink below its initial size 42 | 43 | 44 | Will shrink 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/interactivity/outline.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Outline 3 | property: outline 4 | parent: Interactivity 5 | route: /interactivity/outline/ 6 | previousRoute: /interactivity/cursor/ 7 | previousLabel: Cursor 8 | nextRoute: /interactivity/pointer-events/ 9 | nextLabel: Pointer Events 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | Use this utility to remove any `outline` styles (like when you focus on a form field). 17 | 18 | 19 | 20 | Native 21 | 22 | 23 | 24 | 25 | Using{" "} 26 | outline-none 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | Using{" "} 35 | outline-none{" "} 36 | and{" "} 37 | 38 | focus:shadow-outline 39 | 40 | 41 | 42 | 46 | 47 | 48 | 49 | 50 | > With great power comes great responsibility. As this takes visual identifiers away from the user, just remember to give some visual indicator and replace the outline that was removed (Similar to the example above). 51 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/interactivity/pointer-events.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Pointer Events 3 | property: pointer-events 4 | parent: Interactivity 5 | route: /interactivity/pointer-events 6 | previousRoute: /interactivity/outline 7 | previousLabel: Outline 8 | nextRoute: /interactivity/resize 9 | nextLabel: Resize 10 | --- 11 | 12 | import { Box } from "benefit-react" 13 | import UtilityInfo from "../../components/UtilityInfo" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | 17 | 18 | 19 | --- 20 | 21 | This sets whether or not a particular element can become the target of pointer events. The two examples below attempt to show an alert box on click. Notice how the second button never triggers the alert. 22 | 23 | 24 | 25 | alert("Button clicked")} 29 | className="bg-gray-600 text-white w-full p-4 rounded shadow-lg font-semibold uppercase" 30 | > 31 | A Button 32 | 33 | 34 | 38 | alert("Button clicked")} 42 | className="pointer-events-none bg-gray-600 text-white w-full p-4 rounded shadow-lg font-semibold uppercase" 43 | > 44 | A Button 45 | 46 | 47 | 48 | 49 | > In addition to indicating that the element is not the target of pointer events, the value `none` instructs the pointer event to go "through" the element and target whatever is "underneath" that element instead. 50 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/border/border-width.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Border Width 3 | property: border-width 4 | parent: Border 5 | route: /border/border-width/ 6 | previousRoute: /border/border-style/ 7 | previousLabel: Border Style 8 | nextRoute: /flexbox/align-content/ 9 | nextLabel: Align Content 10 | --- 11 | 12 | 17 | 18 | --- 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | --- 39 | 40 | 41 | 42 | --- 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/utilities/flexbox/flex-wrapping.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flex Wrapping 3 | property: flex-wrap 4 | parent: Flexbox 5 | route: /flexbox/flex-wrapping/ 6 | previousRoute: /flexbox/flex-shrink/ 7 | previousLabel: Flex Shrink 8 | nextRoute: /flexbox/justify-content/ 9 | nextLabel: Justify Content 10 | --- 11 | 12 | 13 | 14 | --- 15 | 16 | 17 | 18 | 19 | {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(item => ( 20 | 21 | 22 | {item} 23 | 24 | 25 | ))} 26 | 27 | 28 | 29 | 30 | {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(item => ( 31 | 32 | 33 | {item} 34 | 35 | 36 | ))} 37 | 38 | 39 | 40 | 41 | {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(item => ( 42 | 43 | 44 | {item} 45 | 46 | 47 | ))} 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /packages/benefit/util/insertStyle.ts: -------------------------------------------------------------------------------- 1 | import initializeContainers from "./initializeContainers" 2 | const isBrowser = typeof window !== "undefined" 3 | 4 | function createStyleTag( 5 | id: string, 6 | rules: string, 7 | options: { label?: string; index?: string } = {} 8 | ) { 9 | const { label = "", index = "" } = options 10 | 11 | const styleTag = document.createElement("style") 12 | 13 | styleTag.setAttribute("id", id) 14 | styleTag.setAttribute(`data-benefit${label ? `-${label}` : ""}`, "") 15 | if (index) { 16 | styleTag.setAttribute("data-benefit-index", index) 17 | } 18 | 19 | styleTag.innerHTML = rules 20 | 21 | return styleTag 22 | } 23 | 24 | export default function insertStyle(type: any, entry: any, index: any) { 25 | if (isBrowser) { 26 | initializeContainers() 27 | if (type === "utilities") { 28 | const existingIndex = document.querySelector( 29 | `[data-benefit-index='${entry.index}']` 30 | ) 31 | 32 | if (existingIndex) { 33 | existingIndex.id = entry.id 34 | existingIndex.innerHTML = entry.rules 35 | } else { 36 | const styleTag = createStyleTag(entry.id, entry.rules, { 37 | label: "utility", 38 | index: entry.index, 39 | }) 40 | 41 | const addedStyles = document.querySelectorAll("[data-benefit-utility]") 42 | 43 | const container = document.getElementById("benefit-utilities") 44 | 45 | if (container) { 46 | container.insertBefore(styleTag, addedStyles[index]) 47 | } 48 | } 49 | } else { 50 | if (!document.getElementById(entry.id)) { 51 | const container = document.getElementById(`benefit-${type}`) 52 | if (container) { 53 | container.appendChild(createStyleTag(entry.id, entry.rules)) 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/typography/text-alignment.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Text Alignment 3 | property: text-align 4 | parent: Typography 5 | route: /typography/text-alignment 6 | previousRoute: /typography/style-decoration 7 | previousLabel: Style and Decoration 8 | nextRoute: /typography/text-color 9 | nextLabel: Text Color 10 | --- 11 | 12 | import { Playground } from "docz" 13 | import { Box, ConfigConsumer } from "benefit-react" 14 | import InfoBox from "../../components/InfoBox" 15 | import Grid from "../../components/Grid" 16 | import ConfigPropertyList from "../../components/ConfigPropertyList" 17 | import UtilityInfo from "../../components/UtilityInfo" 18 | 19 | 20 | 21 | --- 22 | 23 | 24 | 25 | 26 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 27 | aesthetic twee tumeric next level hell of heirloom.{" "} 28 | 29 | 30 | 31 | 32 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 33 | aesthetic twee tumeric next level hell of heirloom.{" "} 34 | 35 | 36 | 37 | 38 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 39 | aesthetic twee tumeric next level hell of heirloom.{" "} 40 | 41 | 42 | 43 | 44 | Hoodie waistcoat mlkshk keytar sustainable, everyday carry tofu squid 45 | aesthetic twee tumeric next level hell of heirloom.{" "} 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/utilities/effects/box-shadow.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Box Shadow 3 | property: box-shadow 4 | parent: Effects 5 | route: /effects/box-shadow 6 | previousRoute: /tables/table-layout 7 | previousLabel: Table Layout 8 | nextRoute: /effects/opacity 9 | nextLabel: Opacity 10 | --- 11 | 12 | import { Box, ConfigConsumer } from "benefit-react" 13 | import Grid from "../../components/Grid" 14 | import InfoBox from "../../components/InfoBox" 15 | import ConfigPropertyList from "../../components/ConfigPropertyList" 16 | import UtilityInfo from "../../components/UtilityInfo" 17 | 18 | 19 | 20 | --- 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /packages/benefit-docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "benefit-docs", 3 | "private": true, 4 | "description": "Benefit documentation", 5 | "version": "0.1.0", 6 | "author": "Chad Donohue ", 7 | "dependencies": { 8 | "@babel/core": "^7.5.5", 9 | "@babel/plugin-transform-react-jsx": "^7.3.0", 10 | "@babel/standalone": "^7.6.0", 11 | "@mdx-js/mdx": "^1.1.1", 12 | "@mdx-js/react": "^1.1.1", 13 | "benefit-react": "2.2.0", 14 | "buble": "^0.19.8", 15 | "gatsby": "^2.13.44", 16 | "gatsby-image": "^2.2.7", 17 | "gatsby-plugin-manifest": "^2.2.4", 18 | "gatsby-plugin-mdx": "^1.0.18", 19 | "gatsby-plugin-nprogress": "^2.1.2", 20 | "gatsby-plugin-offline": "^2.2.4", 21 | "gatsby-plugin-react-helmet": "^3.1.2", 22 | "gatsby-plugin-sharp": "^2.2.9", 23 | "gatsby-plugin-typescript": "2.1.2", 24 | "gatsby-source-filesystem": "^2.1.6", 25 | "gatsby-transformer-sharp": "^2.2.5", 26 | "polychrome": "4.1.2", 27 | "prism-react-renderer": "^0.1.7", 28 | "prop-types": "^15.7.2", 29 | "react": "^16.8.6", 30 | "react-dom": "^16.8.6", 31 | "react-element-to-jsx-string": "^14.0.3", 32 | "react-helmet": "^5.2.1", 33 | "react-live": "^2.1.2" 34 | }, 35 | "devDependencies": { 36 | "prettier": "^1.18.2" 37 | }, 38 | "keywords": [ 39 | "gatsby" 40 | ], 41 | "license": "MIT", 42 | "scripts": { 43 | "build": "gatsby build", 44 | "develop": "gatsby develop", 45 | "format": "prettier --write src/**/*.{js,jsx}", 46 | "start": "npm run develop", 47 | "serve": "gatsby serve", 48 | "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"" 49 | }, 50 | "repository": { 51 | "type": "git", 52 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 53 | }, 54 | "bugs": { 55 | "url": "https://github.com/gatsbyjs/gatsby/issues" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/benefit-docs/src/docs/installation/react.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: React 3 | route: /installation/react/ 4 | parent: Installation 5 | previousRoute: /installation/agnostic/ 6 | previousLabel: Installation 7 | nextRoute: /customization/overview/ 8 | nextLabel: Customization 9 | --- 10 | 11 | ```bash 12 | npm i benefit-react 13 | ``` 14 | 15 | > Requires `react` >= `16.3` 16 | 17 | You have two ways of integrating `benefit-react` into your project: 18 | 19 | ### JSX Pragma 20 | 21 | This option requires some additional configuration, but does not require you to wrap each component that you intend to use utility classes with. 22 | 23 | > Similar to a comment containing linter configuration, this configures the jsx babel plugin to use the `jsx` function instead of `React.createElement`. 24 | > 25 | > [JSX Pragma Documentation](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#pragma) 26 | 27 | Set the jsx pragma at the top of your source file and import the `jsx` function from `benefit-react` 28 | 29 | ```js 30 | /** @jsx jsx */ 31 | import { jsx } from "benefit-react" 32 | 33 | export default function MyComponent() { 34 | return
...
35 | } 36 | ``` 37 | 38 | ### Box component 39 | 40 | As an alternative to the `jsx` approach, you can also import the `Box` component and use that as you would render any other component. The same example from above using a `Box` would look like the following: 41 | 42 | ```js 43 | import { Box } from "benefit-react" 44 | 45 | export default function MyComponent() { 46 | return ( 47 | 48 | ... 49 | 50 | ) 51 | } 52 | ``` 53 | 54 | _The `jsx` function is really just passing all of your elements through the `Box` component and applying utility styles. It's up to you which one to use. The `jsx` pragma approach just saves you a bit of typing_ 55 | -------------------------------------------------------------------------------- /packages/benefit-docs-old/customization/overview.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | name: Overview 3 | route: /customization/overview 4 | parent: Customization 5 | previousRoute: /getting-started 6 | previousLabel: Getting Started 7 | nextRoute: /customization/theme 8 | nextLabel: Theme 9 | --- 10 | 11 | `benefit` exposes the methods used to build its own default configuration. You have the option of keeping as much or as little as you want of it. Similar to how you would override a `webpack` config in other tools, just supply a function that will return your configuration. 12 | 13 | ```js 14 | const myConfig = (config) => { 15 | /* modify existing config and return */ 16 | } 17 | ``` 18 | 19 | Your configuration function can be passed into the `benefit` function... 20 | 21 | ```js 22 | import benefit from "benefit" 23 | 24 | const myConfig = (config) => { 25 | /* modify existing config and return */ 26 | } 27 | 28 | const { styleWith } = benefit(myConfig) 29 | 30 | // styleWith is now capable of parsing/injecting any custom utilities that you have created 31 | ``` 32 | 33 | ...or into a react `ConfigProvider`. 34 | 35 | ```js 36 | import { ConfigProvider } from "benefit/react" 37 | 38 | const myConfig = (config) => { 39 | /* modify existing config and return */ 40 | } 41 | const App = () => ( 42 | 43 | {/* Use any utility classes within here */} 44 | 45 | ) 46 | ``` 47 | 48 | The configuration function will be passed in the default configuration should you need to borrow any values to compose with. 49 | 50 | The `config` object has the following shape: 51 | 52 | ```js 53 | { 54 | // This prefix will prepend all utility class names 55 | prefix: "", 56 | theme: {}, 57 | normalize: (theme) => ({}), 58 | utilities: [(theme) => ({}), (theme) => ({}), ...], 59 | variants: [(utilities, theme) => ({}), (utilities, theme) => ({}), ...], 60 | apply: {} 61 | } 62 | ``` 63 | --------------------------------------------------------------------------------