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

feat(radio): radio with tailwind forms #46

Merged
merged 16 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
chore(radio): radio with tailwind forms
  • Loading branch information
anuraghazra committed Jan 21, 2021
commit 6e12cd5e588b91f1af2858ba84bd52a9a27002d2
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@storybook/addon-essentials": "^6.1.14",
"@storybook/addon-links": "^6.1.14",
"@storybook/react": "^6.1.14",
"@tailwindcss/forms": "^0.2.1",
anuraghazra marked this conversation as resolved.
Show resolved Hide resolved
"@testing-library/dom": "^7.29.4",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
Expand Down
1 change: 1 addition & 0 deletions preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ const renderlesskitConfig = {
generateDataClassVariant("is-selection-end", true);
generateDataClassVariant("is-selection-end", true, "lib");
}),
require("@tailwindcss/forms"),
],
};

Expand Down
17 changes: 11 additions & 6 deletions src/radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
RadioProps,
useRadioState,
} from "reakit";
import { useTheme } from "../theme";
import { createContext } from "../utils";
import { forwardRefWithAs } from "../utils/types";

Expand All @@ -22,13 +23,17 @@ export const Radio = forwardRefWithAs<
"input"
>(({ children, className, ...props }, ref) => {
const state = useRadioContext();
const theme = useTheme();

return (
<label className={cx("radio", className)}>
<span className="radio__input">
<ReakitRadio className="sr-only" {...state} {...props} ref={ref} />
<span className="radio__control" />
</span>
<span className="radio__label">{children}</span>
<label className={cx(theme.radio.base, className)}>
<ReakitRadio
className={theme.radio.input}
{...state}
{...props}
ref={ref}
/>
<span>{children}</span>
</label>
);
});
Expand Down
1 change: 0 additions & 1 deletion src/radio/stories/Radio.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "./style.css";
import React from "react";
import { Meta } from "@storybook/react";
import { Radio, RadioGroup } from "../Radio";
Expand Down
8 changes: 4 additions & 4 deletions src/radio/stories/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.radio {
/* .radio {
display: grid;
grid-template-columns: min-content auto;
grid-gap: 0.5em;
Expand Down Expand Up @@ -34,8 +34,8 @@
transform: scale(1);
}
.radio input:checked + .radio__control {
background-color: #27272a;
border: 0em solid #a1a1aa;
background-color: white;
border: 0.35em solid #27272a;
}

.radio input:disabled + .radio__control::before {
Expand All @@ -45,4 +45,4 @@

.radio input:disabled + .radio__control {
border: 0.3em solid #e4e4e7;
}
} */
2 changes: 2 additions & 0 deletions src/theme/defaultTheme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { icon } from "./icon";
import { iconButton } from "./iconButton";
import { spinner } from "./spinner";
import { tag } from "./tag";
import { radio } from "./radio";

const theme = {
alert,
Expand All @@ -22,6 +23,7 @@ const theme = {
iconButton,
spinner,
tag,
radio,
};

export default theme;
4 changes: 4 additions & 0 deletions src/theme/defaultTheme/radio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const radio = {
base: "lib:flex lib:items-center lib:gap-2",
input: "lib:text-gray-800 lib:focus:ring-1 lib:focus:ring-gray-200",
};
95 changes: 52 additions & 43 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2384,6 +2384,13 @@
dependencies:
defer-to-connect "^1.0.1"

"@tailwindcss/forms@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@tailwindcss/forms/-/forms-0.2.1.tgz#3244b185854fae1a7cbe8d2456314d8b2d98cf43"
integrity sha512-czfvEdY+J2Ogfd6RUSr/ZSUmDxTujr34M++YLnp2cCPC3oJ4kFvFMaRXA6cEXKw7F1hJuapdjXRjsXIEXGgORg==
dependencies:
mini-svg-data-uri "^1.2.3"

"@testing-library/dom@^7.28.1", "@testing-library/dom@^7.29.4":
version "7.29.4"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.29.4.tgz#1647c2b478789621ead7a50614ad81ab5ae5b86c"
Expand Down Expand Up @@ -2572,9 +2579,9 @@
pretty-format "^26.0.0"

"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6":
version "7.0.6"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==
version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==

"@types/json5@^0.0.29":
version "0.0.29"
Expand Down Expand Up @@ -2633,9 +2640,9 @@
form-data "^3.0.0"

"@types/node@*", "@types/node@^14.14.21":
version "14.14.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.21.tgz#d934aacc22424fe9622ebf6857370c052eae464e"
integrity sha512-cHYfKsnwllYhjOzuC5q1VpguABBeecUp24yFluHpn/BQaVxB1CuQ1FSRZCzrPxrkIfWISXV2LbeoBthLWg0+0A==
version "14.14.22"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.22.tgz#0d29f382472c4ccf3bd96ff0ce47daf5b7b84b18"
integrity sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -3439,7 +3446,7 @@ array.prototype.flatmap@^1.2.1, array.prototype.flatmap@^1.2.3:
es-abstract "^1.18.0-next.1"
function-bind "^1.1.1"

array.prototype.map@^1.0.1:
array.prototype.map@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/array.prototype.map/-/array.prototype.map-1.0.3.tgz#1609623618d3d84134a37d4a220030c2bd18420b"
integrity sha512-nNcb30v0wfDyIe26Yif3PcV1JXQp4zEeEfupG7L4SRjnD6HLbO5b2a7eVSba53bOx4YCHYMBHt+Fp4vYstneRA==
Expand Down Expand Up @@ -4412,9 +4419,9 @@ camelcase@^6.0.0:
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==

caniuse-lite@^1.0.30001035, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001173:
version "1.0.30001178"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001178.tgz#3ad813b2b2c7d585b0be0a2440e1e233c6eabdbc"
integrity sha512-VtdZLC0vsXykKni8Uztx45xynytOi71Ufx9T8kHptSw9AL4dpqailUJJHavttuzUe1KYuBYtChiWv+BAb7mPmQ==
version "1.0.30001179"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001179.tgz#b0803883b4471a6c62066fb1752756f8afc699c8"
integrity sha512-blMmO0QQujuUWZKyVrD1msR4WNDAqb/UPO1Sw2WWsQ7deoM5bJiicKnWJ1Y0NS/aGINSnKPIWBMw5luX+NDUCA==

capture-exit@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -5920,9 +5927,9 @@ dotgitignore@^2.1.0:
minimatch "^3.0.4"

downshift@^6.0.6:
version "6.0.16"
resolved "https://registry.yarnpkg.com/downshift/-/downshift-6.0.16.tgz#e745ef19f3d25a1274f4366317d1711956c75807"
integrity sha512-mvwLaOyYDE3swVt2NISei0e8RQXvhW+abUqmxBaUPpC7CSVZK5rofvpqdewko0II0zQb6RyTDTcce35gK0cWUg==
version "6.1.0"
resolved "https://registry.yarnpkg.com/downshift/-/downshift-6.1.0.tgz#f008063d9b63935910d9db12ead07979ab51ce66"
integrity sha512-MnEJERij+1pTVAsOPsH3q9MJGNIZuu2sT90uxOCEOZYH6sEzkVGtUcTBVDRQkE8y96zpB7uEbRn24aE9VpHnZg==
dependencies:
"@babel/runtime" "^7.12.5"
compute-scroll-into-view "^1.0.16"
Expand Down Expand Up @@ -5970,9 +5977,9 @@ ejs@^3.1.2:
jake "^10.6.1"

electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.634:
version "1.3.641"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.641.tgz#03f14efd70a7971eff2efc947b3c1d0f717c82b9"
integrity sha512-b0DLhsHSHESC1I+Nx6n4w4Lr61chMd3m/av1rZQhS2IXTzaS5BMM5N+ldWdMIlni9CITMRM09m8He4+YV/92TA==
version "1.3.642"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.642.tgz#8b884f50296c2ae2a9997f024d0e3e57facc2b94"
integrity sha512-cev+jOrz/Zm1i+Yh334Hed6lQVOkkemk2wRozfMF4MtTR7pxf3r3L5Rbd7uX1zMcEqVJ7alJBnJL7+JffkC6FQ==

element-resize-detector@^1.2.1:
version "1.2.1"
Expand Down Expand Up @@ -6123,7 +6130,7 @@ es-abstract@^1.17.0-next.0, es-abstract@^1.17.0-next.1:
string.prototype.trimend "^1.0.1"
string.prototype.trimstart "^1.0.1"

es-abstract@^1.18.0-next.1:
es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2:
version "1.18.0-next.2"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.2.tgz#088101a55f0541f595e7e057199e27ddc8f3a5c2"
integrity sha512-Ih4ZMFHEtZupnUh6497zEL4y2+w8+1ljnCyaTa+adcoafI1GOvMwFlDjBLfWR7y9VLfrjRJe9ocuHY1PSR9jjw==
Expand Down Expand Up @@ -6875,9 +6882,9 @@ flat-cache@^3.0.4:
rimraf "^3.0.2"

flatted@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.0.tgz#a5d06b4a8b01e3a63771daa5cb7a1903e2e57067"
integrity sha512-tW+UkmtNg/jv9CSofAKvgVcO7c2URjhTdW1ZTkcAritblu8tajiYy7YisnIflEwtKssCtOxpnBRoCB7iap0/TA==
version "3.1.1"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469"
integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==

flush-write-stream@^1.0.0:
version "1.1.1"
Expand Down Expand Up @@ -6991,14 +6998,14 @@ fs-extra@^0.30.0:
rimraf "^2.2.8"

fs-extra@^9.0.0, fs-extra@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"
integrity sha512-h2iAoN838FqAFJY2/qVpzFXy+EBxfVE220PalAqQLDVsFOHLJrZvut5puAbCdNv6WJk+B8ihI+k0c7JK5erwqQ==
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^1.0.0"
universalify "^2.0.0"

fs-minipass@^2.0.0:
version "2.1.0"
Expand Down Expand Up @@ -8644,7 +8651,7 @@ iterate-iterator@^1.0.1:
resolved "https://registry.yarnpkg.com/iterate-iterator/-/iterate-iterator-1.0.1.tgz#1693a768c1ddd79c969051459453f082fe82e9f6"
integrity sha512-3Q6tudGN05kbkDQDI4CqjaBf4qf85w6W6GnuZDtUVYwKgtC1q8yxYX7CZed7N+tLzQqS6roujWvszf13T+n9aw==

iterate-value@^1.0.0:
iterate-value@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/iterate-value/-/iterate-value-1.0.2.tgz#935115bd37d006a52046535ebc8d07e9c9337f57"
integrity sha512-A6fMAio4D2ot2r/TYzr4yUWrmwNdsN5xL7+HUiyACE4DXm+q8HtPcnFTp+NnW3k4N05tZ7FVYFFb2CR13NxyHQ==
Expand Down Expand Up @@ -9350,9 +9357,9 @@ lint-staged@^10.5.3:
stringify-object "^3.3.0"

listr2@^3.2.2:
version "3.2.3"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.2.3.tgz#ef9e0d790862f038dde8a9837be552b1adfd1c07"
integrity sha512-vUb80S2dSUi8YxXahO8/I/s29GqnOL8ozgHVLjfWQXa03BNEeS1TpBLjh2ruaqq5ufx46BRGvfymdBSuoXET5w==
version "3.3.0"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.3.0.tgz#fab51211e4152d88bab7d91e4f7f896b0d9e5ba1"
integrity sha512-G9IFI/m65icgVlifS0wMQnvn35/8VJGzEb3crpE4NnaegQYQOn/wP7yqi9TTJQ/eoxme4UaPbffBK1XqKP/DOg==
dependencies:
chalk "^4.1.0"
cli-truncate "^2.1.0"
Expand All @@ -9362,6 +9369,7 @@ listr2@^3.2.2:
p-map "^4.0.0"
rxjs "^6.6.3"
through "^2.3.8"
wrap-ansi "^7.0.0"

load-json-file@^1.0.0:
version "1.1.0"
Expand Down Expand Up @@ -9941,6 +9949,11 @@ min-indent@^1.0.0:
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==

mini-svg-data-uri@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.2.3.tgz#e16baa92ad55ddaa1c2c135759129f41910bc39f"
integrity sha512-zd6KCAyXgmq6FV1mR10oKXYtvmA9vRoB6xPSTUJTbFApCtkefDnYueVR1gkof3KcdLZo1Y8mjF2DFmQMIxsHNQ==

minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"
Expand Down Expand Up @@ -11203,15 +11216,16 @@ promise-inflight@^1.0.1:
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

promise.allsettled@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/promise.allsettled/-/promise.allsettled-1.0.2.tgz#d66f78fbb600e83e863d893e98b3d4376a9c47c9"
integrity sha512-UpcYW5S1RaNKT6pd+s9jp9K9rlQge1UXKskec0j6Mmuq7UJCvlS2J2/s/yuPN8ehftf9HXMxWlKiPbGGUzpoRg==
version "1.0.4"
resolved "https://registry.yarnpkg.com/promise.allsettled/-/promise.allsettled-1.0.4.tgz#65e71f2a604082ed69c548b68603294090ee6803"
integrity sha512-o73CbvQh/OnPFShxHcHxk0baXR2a1m4ozb85ha0H14VEoi/EJJLa9mnPfEWJx9RjA9MLfhdjZ8I6HhWtBa64Ag==
dependencies:
array.prototype.map "^1.0.1"
array.prototype.map "^1.0.3"
call-bind "^1.0.2"
define-properties "^1.1.3"
es-abstract "^1.17.0-next.1"
function-bind "^1.1.1"
iterate-value "^1.0.0"
es-abstract "^1.18.0-next.2"
get-intrinsic "^1.0.2"
iterate-value "^1.0.2"

promise.prototype.finally@^3.1.0:
version "3.1.2"
Expand Down Expand Up @@ -13655,9 +13669,9 @@ typescript@^4.1.3:
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==

uglify-js@^3.1.4:
version "3.12.4"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.12.4.tgz#93de48bb76bb3ec0fc36563f871ba46e2ee5c7ee"
integrity sha512-L5i5jg/SHkEqzN18gQMTWsZk3KelRsfD1wUVNqtq0kzqWQqcJjyL8yc1o8hJgRrWqrAl2mUFbhfznEIoi7zi2A==
version "3.12.5"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.12.5.tgz#83241496087c640efe9dfc934832e71725aba008"
integrity sha512-SgpgScL4T7Hj/w/GexjnBHi3Ien9WS1Rpfg5y91WXMj9SY997ZCQU76mH4TpLwwfmMvoOU8wiaRkIf6NaH3mtg==

unfetch@^4.1.0:
version "4.2.0"
Expand Down Expand Up @@ -13801,11 +13815,6 @@ [email protected], unist-util-visit@^2.0.0:
unist-util-is "^4.0.0"
unist-util-visit-parents "^3.0.0"

universalify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"
integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
Expand Down