diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d98766d --- /dev/null +++ b/.prettierignore @@ -0,0 +1,12 @@ +## file extensions +*.* +!*.css +!*.js +!*.json +!*.jsx +!*.less +!*.md +!*.mdx +!*.ts +!*.tsx +!*.yml diff --git a/.prettierrc b/.prettierrc index a746f39..9f7fc0b 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,6 +4,6 @@ "semi": false, "singleQuote": true, "jsxBracketSameLine": false, - "printWidth": 120, + "printWidth": 200, "arrowParens": "avoid" } diff --git a/bin/lib/new-component.js b/bin/lib/new-component.js index a5d6374..e7c55d8 100755 --- a/bin/lib/new-component.js +++ b/bin/lib/new-component.js @@ -7,7 +7,7 @@ const templateStory = require('../templates/components/Component.story') const templateIndex = require('../templates/components/index') module.exports = (name, folder = 'components') => { - if (! /^[A-Z][a-z]+(?:[A-Z][a-z]+)*$/.test(name)) { + if (!/^[A-Z][a-z]+(?:[A-Z][a-z]+)*$/.test(name)) { console.error(`⚠️ \x1b[4m${name} \x1b[0mis not a valid component name. Try naming your component with pascal case. i.e. \x1b[4mNewComponent\x1b[0m`) return null } diff --git a/bin/lib/writeFile.js b/bin/lib/writeFile.js index 5ec87d8..0565299 100644 --- a/bin/lib/writeFile.js +++ b/bin/lib/writeFile.js @@ -3,11 +3,10 @@ const fs = require('fs') module.exports = function writeFile(filePath, content) { const relativePath = path.relative('.', filePath) - if ( fs.existsSync(filePath) ) { - console.log(`💥 \x1b[31m${relativePath} \x1b[0malready exists`) - } - else { + if (fs.existsSync(filePath)) { + console.log(`💥 \x1b[31m${relativePath} \x1b[0malready exists`) + } else { fs.writeFileSync(filePath, content) - console.log(`👌 \x1b[32m${relativePath} \x1b[0mcreated`) + console.log(`👌 \x1b[32m${relativePath} \x1b[0mcreated`) } } diff --git a/bin/templates/components/Component.js b/bin/templates/components/Component.js index 939e582..00ffa19 100644 --- a/bin/templates/components/Component.js +++ b/bin/templates/components/Component.js @@ -1,6 +1,7 @@ const source = require('common-tags').source -module.exports = (Name) => source` +module.exports = Name => + source` import React from 'react' import { Component } from '../../lib' diff --git a/bin/templates/components/Component.styled.js b/bin/templates/components/Component.styled.js index f7ad9e1..699974d 100644 --- a/bin/templates/components/Component.styled.js +++ b/bin/templates/components/Component.styled.js @@ -1,6 +1,7 @@ const source = require('common-tags').source -module.exports = () => source` +module.exports = () => + source` import styled from 'styled-components' export const Root = styled.div\` diff --git a/components/Accordion/Accordion.tsx b/components/Accordion/Accordion.tsx index a19fb56..1bd57f1 100644 --- a/components/Accordion/Accordion.tsx +++ b/components/Accordion/Accordion.tsx @@ -22,11 +22,7 @@ type CompoundComponent = { Item: Component } -export const Accordion: Component & CompoundComponent = ({ - children, - defaultSelected = -1, - ...props -}) => { +export const Accordion: Component & CompoundComponent = ({ children, defaultSelected = -1, ...props }) => { const [selected, setSelected] = useState(defaultSelected) /** Update Selected when prop changes */ diff --git a/components/Breadcrumbs/Breadcrumbs.tsx b/components/Breadcrumbs/Breadcrumbs.tsx index 50004e0..0d2f4ac 100644 --- a/components/Breadcrumbs/Breadcrumbs.tsx +++ b/components/Breadcrumbs/Breadcrumbs.tsx @@ -15,13 +15,7 @@ export type BreadcrumbsProps = { > } -export const Breadcrumbs: Component = ({ - loading, - divider = '', - items = [], - prefix = '', - ...props -}) => { +export const Breadcrumbs: Component = ({ loading, divider = '', items = [], prefix = '', ...props }) => { return ( {loading ? ( diff --git a/components/BubbleCarousel/BubbleCarousel.tsx b/components/BubbleCarousel/BubbleCarousel.tsx index e4f6802..5e6f4c6 100644 --- a/components/BubbleCarousel/BubbleCarousel.tsx +++ b/components/BubbleCarousel/BubbleCarousel.tsx @@ -22,16 +22,7 @@ export const BubbleCarousel: Component = ({ children, loadi const [scrollerRef, setScrollerRef] = useState>() return ( - + {loading ? ( <> diff --git a/components/Button/Button.tsx b/components/Button/Button.tsx index 4209181..5b2d7c6 100644 --- a/components/Button/Button.tsx +++ b/components/Button/Button.tsx @@ -10,14 +10,7 @@ export type ButtonProps = Props<{ loading?: LoaderProps }> -export const Button: Component = ({ - text, - children = text, - loading, - secondary = false, - outline = false, - ...props -}) => { +export const Button: Component = ({ text, children = text, loading, secondary = false, outline = false, ...props }) => { return ( {!!loading ? : {children}} diff --git a/components/Carousel/Carousel.story.tsx b/components/Carousel/Carousel.story.tsx index 84e619b..c44e973 100644 --- a/components/Carousel/Carousel.story.tsx +++ b/components/Carousel/Carousel.story.tsx @@ -15,13 +15,7 @@ const Item = styled.div` ` storiesOf('📦 Components/Carousel', module).add('Default', () => ( - + 1 diff --git a/components/Carousel/Carousel.styled.tsx b/components/Carousel/Carousel.styled.tsx index 6b760bf..af663ae 100644 --- a/components/Carousel/Carousel.styled.tsx +++ b/components/Carousel/Carousel.styled.tsx @@ -24,8 +24,7 @@ export const Scroller = styled.div<{ -webkit-overflow-scrolling: touch; display: grid; - grid-auto-columns: ${props => - props.$show === 'auto' ? 'max-content' : 'calc(100% / var(--show) - var(--padding))'}; + grid-auto-columns: ${props => (props.$show === 'auto' ? 'max-content' : 'calc(100% / var(--show) - var(--padding))')}; grid-auto-flow: column; grid-gap: var(--gap); overflow-x: scroll; diff --git a/components/Carousel/Carousel.tsx b/components/Carousel/Carousel.tsx index 396c245..fcff1e7 100644 --- a/components/Carousel/Carousel.tsx +++ b/components/Carousel/Carousel.tsx @@ -18,16 +18,7 @@ type CompoundComponent = { Item: Component } -export const Carousel: Component & CompoundComponent = ({ - children, - gap = 0, - padding = 0, - show = 1, - hideScrollBar = false, - snap = true, - scrollerRef, - ...props -}) => { +export const Carousel: Component & CompoundComponent = ({ children, gap = 0, padding = 0, show = 1, hideScrollBar = false, snap = true, scrollerRef, ...props }) => { const rootElemRef = useRef(null) const scrollerElemRef = useRef(null) const { height } = useMeasure(rootElemRef) @@ -40,15 +31,7 @@ export const Carousel: Component & CompoundComponent = ({ return ( - 1 ? padding : 0} - $show={show} - $gap={gap} - $hideScrollBar={hideScrollBar} - $snap={snap} - {...props} - > + 1 ? padding : 0} $show={show} $gap={gap} $hideScrollBar={hideScrollBar} $snap={snap} {...props}> {children} diff --git a/components/CartList/CartList.tsx b/components/CartList/CartList.tsx index f0691e1..ee5a48e 100644 --- a/components/CartList/CartList.tsx +++ b/components/CartList/CartList.tsx @@ -1,19 +1,6 @@ import React from 'react' import { Component, Props } from '../../lib' -import { - Root, - Product, - Thumbnail, - DetailsWrapper, - Title, - Price, - Quantity, - Sku, - Options, - Option, - OptionLabel, - OptionValue, -} from './CartList.styled' +import { Root, Product, Thumbnail, DetailsWrapper, Title, Price, Quantity, Sku, Options, Option, OptionLabel, OptionValue } from './CartList.styled' import PriceComponent, { PriceProps } from '../Price' import Image, { ImageProps } from '../Image' import QuantityComponent, { QuantityProps } from '../Quantity' @@ -47,14 +34,7 @@ export const CartList: Component = ({ loading, items, children, . {items?.map(({ _id, title, sku, thumbnail, price, quantity, options }, index) => ( - + {title.text} diff --git a/components/CartSummary/CartSummary.styled.tsx b/components/CartSummary/CartSummary.styled.tsx index 847a2f2..2210eb1 100644 --- a/components/CartSummary/CartSummary.styled.tsx +++ b/components/CartSummary/CartSummary.styled.tsx @@ -1,9 +1,5 @@ import styled from 'styled-components' -import { - Button as AccordionButton, - Content as AccordionContent, - ButtonLabel as AccordionLabel, -} from '../Accordion/Accordion.styled' +import { Button as AccordionButton, Content as AccordionContent, ButtonLabel as AccordionLabel } from '../Accordion/Accordion.styled' export const Root = styled.div` display: grid; diff --git a/components/Checkout/ApplyCouponForm/ApplyCouponForm.tsx b/components/Checkout/ApplyCouponForm/ApplyCouponForm.tsx index 3f8c8e5..835417f 100644 --- a/components/Checkout/ApplyCouponForm/ApplyCouponForm.tsx +++ b/components/Checkout/ApplyCouponForm/ApplyCouponForm.tsx @@ -16,15 +16,7 @@ export type ApplyCouponFormProps = FormProps & { error?: string } -export const ApplyCouponForm: Component = ({ - field, - loading = false, - onSubmit, - submitButton, - submitting = false, - error, - ...props -}) => { +export const ApplyCouponForm: Component = ({ field, loading = false, onSubmit, submitButton, submitting = false, error, ...props }) => { return ( diff --git a/components/Checkout/ContactInfoForm/ContactInfoForm.tsx b/components/Checkout/ContactInfoForm/ContactInfoForm.tsx index 013e9c3..e73268c 100644 --- a/components/Checkout/ContactInfoForm/ContactInfoForm.tsx +++ b/components/Checkout/ContactInfoForm/ContactInfoForm.tsx @@ -1,19 +1,6 @@ import React, { useCallback } from 'react' import { Component } from '../../../lib' -import { - Root, - Email, - FirstName, - LastName, - Company, - Address1, - Address2, - City, - Country, - Region, - PostalCode, - PhoneNumber, -} from './ContactInfoForm.styled' +import { Root, Email, FirstName, LastName, Company, Address1, Address2, City, Country, Region, PostalCode, PhoneNumber } from './ContactInfoForm.styled' import Form, { FormProps, Input, InputProps, Select, SelectProps, FormError, patterns } from '../../Form' import Button, { ButtonProps } from '../../Button' @@ -56,18 +43,7 @@ export type ContactInfoFormProps = FormProps & { error?: string } -export const ContactInfoForm: Component = ({ - edit = false, - fields, - submitButton, - editButton, - onSubmit, - onEdit, - loading, - submitting, - error, - ...props -}) => { +export const ContactInfoForm: Component = ({ edit = false, fields, submitButton, editButton, onSubmit, onEdit, loading, submitting, error, ...props }) => { const handleOnClickEdit = useCallback( (e: Event) => { e.preventDefault() @@ -84,12 +60,7 @@ export const ContactInfoForm: Component = ({
- + @@ -129,11 +100,7 @@ export const ContactInfoForm: Component = ({ {error && {error}} - {edit ? ( -