Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/generator #27

Merged
merged 18 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/components/Nav/Desktop/DesktopNavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function DesktopNavLink({ children, link, name }) {
{children.map(({ route, name, children }, i) => {
i += 1;
return (
<ChildLinkContainer>
<ChildLinkContainer key={`${name}-${i}`}>
<LinkItem>
<Counter>
<LinkCount>{`0${i}`.slice(-2)}</LinkCount>
Expand Down
2 changes: 1 addition & 1 deletion docs/hooks/useMatchMedia.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRef, useState, useCallback, useEffect } from 'react';

export function useMatchMedia(query: string) {
export function useMatchMedia(query: string): boolean {
const matchListRef = useRef<MediaQueryList | null>(null);
const [isMatch, setIsMatch] = useState<boolean>(false);
const onMediaQueryListEvent = useCallback((e: MediaQueryListEvent) => {
Expand Down
8 changes: 4 additions & 4 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"dependencies": {
"artifak": "^1.1.5",
"csstype": "^3.0.5",
"framer-motion": "^3.0.0",
"framer-motion": "^3.1.1",
"lodash.isplainobject": "^4.0.6",
"next": "10.0.3",
"next-seo": "^4.17.0",
"react": "^16.14.0",
"react": "^17.0.1",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "^16.14.0",
"react-dom": "^17.0.1",
"react-intl": "^5.10.9",
"react-markings": "^1.3.0",
"react-spring": "^8.0.27",
Expand All @@ -29,7 +29,7 @@
"devDependencies": {
"@types/node": "^14.14.14",
"@types/react": "^17.0.0",
"@types/styled-components": "^5.1.6",
"@types/styled-components": "^5.1.7",
"@types/styled-system": "^5.1.10",
"babel-plugin-styled-components": "^1.12.0",
"typescript": "^4.1.3"
Expand Down
92 changes: 40 additions & 52 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,6 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==

"@types/react-native@*":
version "0.63.8"
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.63.8.tgz#73ec087122c64c309eeaf150b565b8d755f0fb1f"
integrity sha512-QRwGFRTyGafRVTUS+0GYyJrlpmS3boyBaFI0ULSc+mh/lQNxrzbdQvoL2k5X7+t9hxyqA4dTQAlP6l0ir/fNJQ==
dependencies:
"@types/react" "*"

"@types/react@*":
version "16.9.46"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.46.tgz#f0326cd7adceda74148baa9bff6e918632f5069e"
Expand All @@ -510,14 +503,13 @@
"@types/prop-types" "*"
csstype "^3.0.2"

"@types/styled-components@^5.1.6":
version "5.1.6"
resolved "https://registry.yarnpkg.com/@types/styled-components/-/styled-components-5.1.6.tgz#b47460f1684072576999955b5b5153e6f238622c"
integrity sha512-YN1j99dOL92T+76qhQcrPUb2nKZLzawko9j3IIwTHdKloMx20WwcGkBwdpbi8SpAkTc362rgfIllqPdSUplmRw==
"@types/styled-components@^5.1.7":
version "5.1.7"
resolved "https://registry.yarnpkg.com/@types/styled-components/-/styled-components-5.1.7.tgz#3cd10b088c1cb1acde2e4b166b3e8275a3083710"
integrity sha512-BJzPhFygYspyefAGFZTZ/8lCEY4Tk+Iqktvnko3xmJf9LrLqs3+grxPeU3O0zLl6yjbYBopD0/VikbHgXDbJtA==
dependencies:
"@types/hoist-non-react-statics" "*"
"@types/react" "*"
"@types/react-native" "*"
csstype "^3.0.2"

"@types/styled-system@^5.1.10":
Expand Down Expand Up @@ -2163,25 +2155,23 @@ fragment-cache@^0.2.1:
dependencies:
map-cache "^0.2.2"

framer-motion@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-3.0.0.tgz#71f786ca15ff2c6fa471eb7bcfed57169aae1b0b"
integrity sha512-jCFbtemYiEdjh6snaT9lrTEEbWKYzUNAuckzWx2R/sYa8IDGpWGb/aV5qm1sn4/sgiVGZKnPj25Gzsny/pJxcQ==
framer-motion@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-3.1.1.tgz#a8a779501213b7ce02cc35beb27621d73cc2f1e7"
integrity sha512-Gm1QSb0xUxuhcPar5FIs5Ws+STrhLZ6XZf2Io8dVwFofe1OzwkL9asGFVu7z3y6WqC4Hvnxm7wsW5SBHlxZDYw==
dependencies:
framesync "^4.1.0"
framesync "^5.0.0"
hey-listen "^1.0.8"
popmotion "9.0.1"
style-value-types "^3.1.9"
popmotion "^9.0.2"
style-value-types "^3.2.0"
tslib "^1.10.0"
optionalDependencies:
"@emotion/is-prop-valid" "^0.8.2"

framesync@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/framesync/-/framesync-4.1.0.tgz#69a8db3ca432dc70d6a76ba882684a1497ef068a"
integrity sha512-MmgZ4wCoeVxNbx2xp5hN/zPDCbLSKiDt4BbbslK7j/pM2lg5S0vhTNv1v8BCVb99JPIo6hXBFdwzU7Q4qcAaoQ==
dependencies:
hey-listen "^1.0.5"
framesync@5.0.0, framesync@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/framesync/-/framesync-5.0.0.tgz#7de8caedf53ac441118e79680f1beb7391c328b6"
integrity sha512-wd8t+JsQGisluSv1twiEeDv0aNGpavGb9q7xgIk9fGbcIWkNXF/KVtrjnOrCwBWJuiXxlJfNkcvGudsI32FxYA==

from2@^2.1.0:
version "2.3.0"
Expand Down Expand Up @@ -2381,7 +2371,7 @@ he@1.2.0:
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==

hey-listen@^1.0.5, hey-listen@^1.0.8:
hey-listen@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/hey-listen/-/hey-listen-1.0.8.tgz#8e59561ff724908de1aa924ed6ecc84a56a9aa68"
integrity sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q==
Expand Down Expand Up @@ -3462,14 +3452,14 @@ pnp-webpack-plugin@1.6.4:
dependencies:
ts-pnp "^1.1.6"

popmotion@9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/popmotion/-/popmotion-9.0.1.tgz#63657089c124ffad500c45e6eb20b8e3cca919af"
integrity sha512-pXBHRaLz/WBlatXb0ADPGXksqr24z24z1H2/xTtsin9E6dJ0bGK1nWyZpcvdjDIIf8XxAkbf3/FN3JxayVmFbQ==
popmotion@^9.0.2:
version "9.0.2"
resolved "https://registry.yarnpkg.com/popmotion/-/popmotion-9.0.2.tgz#477650c3b4af97161011809223d9ca6860f3a2b5"
integrity sha512-WfSg8IfoUwYIP9uqeqbgncIsMHLAKWqebT2IP1aGAI6gdSJqTPy/H8NvP4ZyDtDCUCx5Yh3Pth/7iUJjIwR7LA==
dependencies:
framesync "^4.1.0"
framesync "5.0.0"
hey-listen "^1.0.8"
style-value-types "^3.1.9"
style-value-types "3.2.0"
tslib "^1.10.0"

posix-character-classes@^0.1.0:
Expand Down Expand Up @@ -3607,7 +3597,7 @@ promise-inflight@^1.0.1:
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

prop-types@15.7.2, prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.2:
prop-types@15.7.2, prop-types@^15.5.10, prop-types@^15.5.8:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -3741,15 +3731,14 @@ react-custom-scrollbars@^4.2.1:
prop-types "^15.5.10"
raf "^3.1.0"

react-dom@^16.14.0:
version "16.14.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.14.0.tgz#7ad838ec29a777fb3c75c3a190f661cf92ab8b89"
integrity sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==
react-dom@^17.0.1:
version "17.0.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.1.tgz#1de2560474ec9f0e334285662ede52dbc5426fc6"
integrity sha512-6eV150oJZ9U2t9svnsspTMrWNyHc6chX0KzDeAOXftRa8bNeOKTTfCJ7KorIwenkHd2xqVTBTCZd79yk/lx/Ug==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.19.1"
scheduler "^0.20.1"

react-intl@^5.10.9:
version "5.10.9"
Expand Down Expand Up @@ -3806,14 +3795,13 @@ react-syntax-highlighter@^15.4.3:
prismjs "^1.22.0"
refractor "^3.2.0"

react@^16.14.0:
version "16.14.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
integrity sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==
react@^17.0.1:
version "17.0.1"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127"
integrity sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"

"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6:
version "2.3.7"
Expand Down Expand Up @@ -3996,10 +3984,10 @@ sass-loader@10.0.5:
schema-utils "^3.0.0"
semver "^7.3.2"

scheduler@^0.19.1:
version "0.19.1"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196"
integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==
scheduler@^0.20.1:
version "0.20.1"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.1.tgz#da0b907e24026b01181ecbc75efdc7f27b5a000c"
integrity sha512-LKTe+2xNJBNxu/QhHvDR14wUXHRQbVY5ZOYpOGWRzhydZUqrLb2JBvLPY7cAqFmqrWuDED0Mjk7013SZiOz6Bw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
Expand Down Expand Up @@ -4391,10 +4379,10 @@ style-loader@1.2.1:
loader-utils "^2.0.0"
schema-utils "^2.6.6"

style-value-types@^3.1.9:
version "3.1.9"
resolved "https://registry.yarnpkg.com/style-value-types/-/style-value-types-3.1.9.tgz#faf7da660d3f284ed695cff61ea197d85b9122cc"
integrity sha512-050uqgB7WdvtgacoQKm+4EgKzJExVq0sieKBQQtJiU3Muh6MYcCp4T3M8+dfl6VOF2LR0NNwXBP1QYEed8DfIw==
style-value-types@3.2.0, style-value-types@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/style-value-types/-/style-value-types-3.2.0.tgz#eb89cab1340823fa7876f3e289d29d99c92111bb"
integrity sha512-ih0mGsrYYmVvdDi++/66O6BaQPRPRMQHoZevNNdMMcPlP/cH28Rnfsqf1UEba/Bwfuw9T8BmIMwbGdzsPwQKrQ==
dependencies:
hey-listen "^1.0.8"
tslib "^1.10.0"
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"release": "yarn build && changeset publish"
},
"peerDependencies": {
"react": "16.11.0",
"react-dom": "16.11.0"
"react": ">=17.0.1",
"react-dom": ">=17.0.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
Expand Down Expand Up @@ -61,5 +61,9 @@
},
"dependencies": {
"@changesets/cli": "^2.12.0"
},
"resolutions": {
"react": ">=17.0.1",
"react-dom": ">=17.0.1"
}
}
11 changes: 0 additions & 11 deletions packages/block/index.stories.mdx

This file was deleted.

41 changes: 41 additions & 0 deletions packages/block/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { BlockBase, createBlockComponents } from './src';

export function BlockBaseUsage() {
return <BlockBase>A Block Base</BlockBase>;
}

const base = {
styles: {
width: '100%',
maxWidth: ['480px', '768px', '1024px', '1200px'],
padding: ['1em', '1.5em'],
margin: '0 auto'
}
};

const components = {
FlexContainer: {
display: 'flex'
},

UnpaddedContainer: {
padding: 0
}
};

const { FlexContainer, UnpaddedContainer } = createBlockComponents<
typeof components
>(base, components);

export function CreateBlocksUsage() {
return (
<>
<FlexContainer>Flex Container</FlexContainer>
<UnpaddedContainer>Unpadded Container</UnpaddedContainer>
</>
);
}

export default {
title: 'Block'
};
22 changes: 12 additions & 10 deletions packages/block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"test": "__tests__",
"src": "src"
},
"files": ["dist"],
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
Expand All @@ -41,19 +43,19 @@
},
"devDependencies": {
"@artifak/bundler": "^1.1.3",
"@types/react": "^16.9.48",
"@types/react-dom": "^16.9.8",
"@types/styled-components": "^5.1.3",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/styled-components": "^5.1.7",
"@types/styled-system": "^5.1.10",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"styled-components": "^4.4.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"styled-components": "^5.2.1",
"styled-system": "^5.1.5"
},
"peerDependencies": {
"react": ">=16.11.0",
"react-dom": ">=16.11.0",
"styled-components": ">=4.4.1"
"react": ">=17.0.1",
"react-dom": ">=17.0.1",
"styled-components": ">=5.2.1"
},
"dependencies": {
"@artifak/component-generator": "^1.1.4"
Expand Down
28 changes: 20 additions & 8 deletions packages/block/src/createBlockComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import React from 'react';
import { createBaseComponents } from '@artifak/component-generator';
import { BlockBaseProps } from './typings';
import { BlockBase } from './BlockBase';
import {
createBaseComponents,
GenericRecord,
Settings,
StyledComponentConfig,
Variant
} from '@artifak/component-generator';

/* eslint-disable @typescript-eslint/no-explicit-any */
export function createBlockComponents<S>(
styles: S
): { [key in keyof any]: React.ComponentType<BlockBaseProps> } {
return createBaseComponents<S, BlockBaseProps>(BlockBase, styles);
export function createBlockComponents<
Config,
ThemeType = any,
Props = Record<string, unknown>,
Element = HTMLDivElement
>(
base: StyledComponentConfig<Props, ThemeType, Element>,
settings: Settings
): GenericRecord<Config, React.FC<Props & Variant<ThemeType>>> {
return createBaseComponents<Config, ThemeType, Props, Element>(
base,
settings
);
}
Loading