Skip to content

Commit 58fa11e

Browse files
committed
feat: add custom-styles story
1 parent faa87d7 commit 58fa11e

File tree

4 files changed

+130
-13
lines changed

4 files changed

+130
-13
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"parserOptions": {
55
"project": ["./tsconfig.json"]
66
},
7-
"plugins": ["@typescript-eslint"],
7+
"plugins": ["@typescript-eslint", "babel-plugin-styled-components"],
88
"extends": [
99
"eslint:recommended",
1010
"plugin:@typescript-eslint/recommended",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"@typescript-eslint/eslint-plugin": "^5.38.0",
8282
"@typescript-eslint/parser": "^5.38.0",
8383
"babel-loader": "^8.2.5",
84+
"babel-plugin-styled-components": "^2.0.7",
8485
"cross-env": "^7.0.3",
8586
"dotenv-cli": "^6.0.0",
8687
"eslint": "^8.23.1",
@@ -102,6 +103,7 @@
102103
"rollup": "^2.79.0",
103104
"rollup-plugin-postcss": "^4.0.2",
104105
"rollup-plugin-typescript2": "^0.34.0",
106+
"styled-components": "^5.3.5",
105107
"typescript": "^4.8.3"
106108
},
107109
"author": "Ugo Onali",

src/index.stories.tsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import { ComponentMeta, ComponentStory } from '@storybook/react';
33
import ReactInputVerificationCode from './';
4+
import styled from 'styled-components';
45

56
export default {
67
title: 'ReactInputVerificationCode',
@@ -21,6 +22,11 @@ const Template: ComponentStory<typeof ReactInputVerificationCode> = (args) => (
2122

2223
export const Default = Template.bind({});
2324

25+
export const WithDefaultValue = Template.bind({});
26+
WithDefaultValue.args = {
27+
value: '7890',
28+
};
29+
2430
export const CustomLength = Template.bind({});
2531
CustomLength.args = {
2632
length: 6,
@@ -44,7 +50,31 @@ CustomType.argTypes = {
4450
},
4551
};
4652

47-
export const WithDefaultValue = Template.bind({});
48-
WithDefaultValue.args = {
49-
value: '7890',
50-
};
53+
const CustomStylesContainer = styled.div`
54+
position: relative;
55+
56+
.ReactInputVerificationCode-item {
57+
width: 2.5rem;
58+
height: 3.5rem;
59+
color: #262626;
60+
font-weight: 500;
61+
border-radius: 0;
62+
border-bottom: 1px solid #ddd;
63+
transition: border-bottom-color 0.2s ease-out;
64+
}
65+
66+
.ReactInputVerificationCode-item:focus {
67+
border-bottom-color: #046cde;
68+
}
69+
70+
.ReactInputVerificationCode-item,
71+
.ReactInputVerificationCode-item:focus {
72+
box-shadow: none;
73+
}
74+
`;
75+
76+
export const CustomStyles = () => (
77+
<CustomStylesContainer>
78+
<ReactInputVerificationCode placeholder='' />
79+
</CustomStylesContainer>
80+
);

yarn.lock

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@jridgewell/gen-mapping" "^0.3.2"
8080
jsesc "^2.5.1"
8181

82-
"@babel/helper-annotate-as-pure@^7.18.6":
82+
"@babel/helper-annotate-as-pure@^7.16.0", "@babel/helper-annotate-as-pure@^7.18.6":
8383
version "7.18.6"
8484
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz#eaa49f6f80d5a33f9a5dd2276e6d6e451be0a6bb"
8585
integrity sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==
@@ -185,7 +185,7 @@
185185
dependencies:
186186
"@babel/types" "^7.18.9"
187187

188-
"@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.18.6":
188+
"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.16.0", "@babel/helper-module-imports@^7.18.6":
189189
version "7.18.6"
190190
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e"
191191
integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==
@@ -1099,7 +1099,7 @@
10991099
"@babel/parser" "^7.18.10"
11001100
"@babel/types" "^7.18.10"
11011101

1102-
"@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.19.0", "@babel/traverse@^7.19.1":
1102+
"@babel/traverse@^7.1.6", "@babel/traverse@^7.12.11", "@babel/traverse@^7.12.9", "@babel/traverse@^7.13.0", "@babel/traverse@^7.19.0", "@babel/traverse@^7.19.1", "@babel/traverse@^7.4.5":
11031103
version "7.19.1"
11041104
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.19.1.tgz#0fafe100a8c2a603b4718b1d9bf2568d1d193347"
11051105
integrity sha512-0j/ZfZMxKukDaag2PtOPDbwuELqIar6lLskVPPJDjXMXjfLb1Obo/1yjxIGqqAJrmfaTIY3z2wFLAQ7qSkLsuA==
@@ -1198,6 +1198,28 @@
11981198
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
11991199
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==
12001200

1201+
"@emotion/is-prop-valid@^1.1.0":
1202+
version "1.2.0"
1203+
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.2.0.tgz#7f2d35c97891669f7e276eb71c83376a5dc44c83"
1204+
integrity sha512-3aDpDprjM0AwaxGE09bOPkNxHpBd+kA6jty3RnaEXdweX1DF1U3VQpPYb0g1IStAuK7SVQ1cy+bNBBKp4W3Fjg==
1205+
dependencies:
1206+
"@emotion/memoize" "^0.8.0"
1207+
1208+
"@emotion/memoize@^0.8.0":
1209+
version "0.8.0"
1210+
resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.8.0.tgz#f580f9beb67176fa57aae70b08ed510e1b18980f"
1211+
integrity sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==
1212+
1213+
"@emotion/stylis@^0.8.4":
1214+
version "0.8.5"
1215+
resolved "https://registry.yarnpkg.com/@emotion/stylis/-/stylis-0.8.5.tgz#deacb389bd6ee77d1e7fcaccce9e16c5c7e78e04"
1216+
integrity sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ==
1217+
1218+
"@emotion/unitless@^0.7.4":
1219+
version "0.7.5"
1220+
resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed"
1221+
integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==
1222+
12011223
"@eslint/eslintrc@^1.3.2":
12021224
version "1.3.2"
12031225
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.2.tgz#58b69582f3b7271d8fa67fe5251767a5b38ea356"
@@ -3808,6 +3830,22 @@ babel-plugin-react-docgen@^4.2.1:
38083830
lodash "^4.17.15"
38093831
react-docgen "^5.0.0"
38103832

3833+
"babel-plugin-styled-components@>= 1.12.0", babel-plugin-styled-components@^2.0.7:
3834+
version "2.0.7"
3835+
resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.7.tgz#c81ef34b713f9da2b7d3f5550df0d1e19e798086"
3836+
integrity sha512-i7YhvPgVqRKfoQ66toiZ06jPNA3p6ierpfUuEWxNF+fV27Uv5gxBkf8KZLHUCc1nFA9j6+80pYoIpqCeyW3/bA==
3837+
dependencies:
3838+
"@babel/helper-annotate-as-pure" "^7.16.0"
3839+
"@babel/helper-module-imports" "^7.16.0"
3840+
babel-plugin-syntax-jsx "^6.18.0"
3841+
lodash "^4.17.11"
3842+
picomatch "^2.3.0"
3843+
3844+
babel-plugin-syntax-jsx@^6.18.0:
3845+
version "6.18.0"
3846+
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"
3847+
integrity sha512-qrPaCSo9c8RHNRHIotaufGbuOBN8rtdC4QrrFFc43vyWCCz7Kl7GL1PGaXtMGQZUXrkCjNEgxDfmAuAabr/rlw==
3848+
38113849
bail@^1.0.0:
38123850
version "1.0.5"
38133851
resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.5.tgz#b6fa133404a392cbc1f8c4bf63f5953351e7a776"
@@ -4292,6 +4330,11 @@ camelcase@^7.0.0:
42924330
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-7.0.0.tgz#fd112621b212126741f998d614cbc2a8623fd174"
42934331
integrity sha512-JToIvOmz6nhGsUhAYScbo2d6Py5wojjNfoxoc2mEVLUdJ70gJK2gnd+ABY1Tc3sVMyK7QDPtN0T/XdlCQWITyQ==
42944332

4333+
camelize@^1.0.0:
4334+
version "1.0.0"
4335+
resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b"
4336+
integrity sha512-W2lPwkBkMZwFlPCXhIlYgxu+7gC/NUlCtdK652DAJ1JdgV0sTrvuPFshNPrFa1TY2JOkLhgdeEBplB4ezEa+xg==
4337+
42954338
caniuse-api@^3.0.0:
42964339
version "3.0.0"
42974340
resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0"
@@ -4923,6 +4966,11 @@ crypto-random-string@^4.0.0:
49234966
dependencies:
49244967
type-fest "^1.0.1"
49254968

4969+
css-color-keywords@^1.0.0:
4970+
version "1.0.0"
4971+
resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05"
4972+
integrity sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==
4973+
49264974
css-declaration-sorter@^6.3.0:
49274975
version "6.3.1"
49284976
resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz#be5e1d71b7a992433fb1c542c7a1b835e45682ec"
@@ -4974,6 +5022,15 @@ css-select@^4.1.3:
49745022
domutils "^2.8.0"
49755023
nth-check "^2.0.1"
49765024

5025+
css-to-react-native@^3.0.0:
5026+
version "3.0.0"
5027+
resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-3.0.0.tgz#62dbe678072a824a689bcfee011fc96e02a7d756"
5028+
integrity sha512-Ro1yETZA813eoyUp2GDBhG2j+YggidUmzO1/v9eYBKR2EHVEniE2MI/NqpTQ954BMpTPZFsGNPm46qFB9dpaPQ==
5029+
dependencies:
5030+
camelize "^1.0.0"
5031+
css-color-keywords "^1.0.0"
5032+
postcss-value-parser "^4.0.2"
5033+
49775034
css-tree@^1.1.2, css-tree@^1.1.3:
49785035
version "1.1.3"
49795036
resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d"
@@ -7015,6 +7072,13 @@ hmac-drbg@^1.0.1:
70157072
minimalistic-assert "^1.0.0"
70167073
minimalistic-crypto-utils "^1.0.1"
70177074

7075+
hoist-non-react-statics@^3.0.0:
7076+
version "3.3.2"
7077+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45"
7078+
integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==
7079+
dependencies:
7080+
react-is "^16.7.0"
7081+
70187082
hosted-git-info@^2.1.4:
70197083
version "2.8.9"
70207084
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
@@ -8282,7 +8346,7 @@ lodash.uniq@4.5.0, lodash.uniq@^4.5.0:
82828346
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
82838347
integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==
82848348

8285-
lodash@4.17.21, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21:
8349+
lodash@4.17.21, lodash@^4.17.11, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21:
82868350
version "4.17.21"
82878351
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
82888352
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@@ -9979,7 +10043,7 @@ postcss-unique-selectors@^5.1.1:
997910043
dependencies:
998010044
postcss-selector-parser "^6.0.5"
998110045

9982-
postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0:
10046+
postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0:
998310047
version "4.2.0"
998410048
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
998510049
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==
@@ -10365,7 +10429,7 @@ react-is@17.0.2, react-is@^17.0.1:
1036510429
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
1036610430
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
1036710431

10368-
react-is@^16.13.1:
10432+
react-is@^16.13.1, react-is@^16.7.0:
1036910433
version "16.13.1"
1037010434
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
1037110435
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
@@ -11133,6 +11197,11 @@ shallow-clone@^3.0.0:
1113311197
dependencies:
1113411198
kind-of "^6.0.2"
1113511199

11200+
shallowequal@^1.1.0:
11201+
version "1.1.0"
11202+
resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8"
11203+
integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==
11204+
1113611205
shebang-command@^1.2.0:
1113711206
version "1.2.0"
1113811207
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
@@ -11632,6 +11701,22 @@ style-to-object@0.3.0, style-to-object@^0.3.0:
1163211701
dependencies:
1163311702
inline-style-parser "0.1.1"
1163411703

11704+
styled-components@^5.3.5:
11705+
version "5.3.5"
11706+
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-5.3.5.tgz#a750a398d01f1ca73af16a241dec3da6deae5ec4"
11707+
integrity sha512-ndETJ9RKaaL6q41B69WudeqLzOpY1A/ET/glXkNZ2T7dPjPqpPCXXQjDFYZWwNnE5co0wX+gTCqx9mfxTmSIPg==
11708+
dependencies:
11709+
"@babel/helper-module-imports" "^7.0.0"
11710+
"@babel/traverse" "^7.4.5"
11711+
"@emotion/is-prop-valid" "^1.1.0"
11712+
"@emotion/stylis" "^0.8.4"
11713+
"@emotion/unitless" "^0.7.4"
11714+
babel-plugin-styled-components ">= 1.12.0"
11715+
css-to-react-native "^3.0.0"
11716+
hoist-non-react-statics "^3.0.0"
11717+
shallowequal "^1.1.0"
11718+
supports-color "^5.5.0"
11719+
1163511720
stylehacks@^5.1.0:
1163611721
version "5.1.0"
1163711722
resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-5.1.0.tgz#a40066490ca0caca04e96c6b02153ddc39913520"
@@ -11640,7 +11725,7 @@ stylehacks@^5.1.0:
1164011725
browserslist "^4.16.6"
1164111726
postcss-selector-parser "^6.0.4"
1164211727

11643-
supports-color@^5.3.0:
11728+
supports-color@^5.3.0, supports-color@^5.5.0:
1164411729
version "5.5.0"
1164511730
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
1164611731
integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==

0 commit comments

Comments
 (0)