From b68cca53a7b8f2c94ecf87d29f96d2c45d662dbf Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 23 Feb 2022 19:22:56 -0800 Subject: [PATCH 01/20] Create Raid.d.ts --- types/Raid.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 types/Raid.d.ts diff --git a/types/Raid.d.ts b/types/Raid.d.ts new file mode 100644 index 00000000..7512b944 --- /dev/null +++ b/types/Raid.d.ts @@ -0,0 +1,9 @@ +interface Raid { + id: string + name: { + en: string + jp: string + } + level: number + group: number +} \ No newline at end of file From 094d2e83d6ad28278fce14842923e62d265968b8 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 23 Feb 2022 19:23:04 -0800 Subject: [PATCH 02/20] Add party details to state --- utils/appState.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/appState.tsx b/utils/appState.tsx index 8ed49ba3..d3266802 100644 --- a/utils/appState.tsx +++ b/utils/appState.tsx @@ -6,6 +6,12 @@ interface AppState { party: { id: string | undefined, editable: boolean, + name: { + en: string, + jp: string + } | undefined, + description: string | undefined, + raid: Raid | undefined, element: number, extra: boolean }, @@ -30,6 +36,9 @@ export const initialAppState: AppState = { party: { id: undefined, editable: false, + name: undefined, + description: undefined, + raid: undefined, element: 0, extra: false }, From 45c133f4508ec3d295aff3e18ac46f19bd9b4648 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 23 Feb 2022 19:23:19 -0800 Subject: [PATCH 03/20] Change the sent param for the extra toggle --- components/Party/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/Party/index.tsx b/components/Party/index.tsx index 20ccb684..5da6cb26 100644 --- a/components/Party/index.tsx +++ b/components/Party/index.tsx @@ -38,7 +38,7 @@ const Party = (props: Props) => { let body = { party: { ...(cookies.user) && { user_id: cookies.user.user_id }, - is_extra: extra + extra: extra } } @@ -51,7 +51,7 @@ const Party = (props: Props) => { if (party.id) { api.endpoints.parties.update(party.id, { - 'party': { 'is_extra': event.target.checked } + 'party': { 'extra': event.target.checked } }, headers) } } From 0a096e9dc016d6cef45737d9ccc7d37df4213f6b Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 23 Feb 2022 19:23:31 -0800 Subject: [PATCH 04/20] Store party details in state when data is fetched --- components/CharacterGrid/index.tsx | 13 +++++++++++++ components/SummonGrid/index.tsx | 13 +++++++++++++ components/WeaponGrid/index.tsx | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx index 4a1eb463..e8b63548 100644 --- a/components/CharacterGrid/index.tsx +++ b/components/CharacterGrid/index.tsx @@ -78,6 +78,19 @@ const CharacterGrid = (props: Props) => { // Store the important party and state-keeping values appState.party.id = party.id + // Store the party's user-generated details + if (party.name) { + appState.party.name = { + en: party.name.en, + jp: party.name.jp + } + } + if (party.description) + appState.party.description = party.description + + if (party.raid) + appState.raid = party.raid + setFound(true) setLoading(false) diff --git a/components/SummonGrid/index.tsx b/components/SummonGrid/index.tsx index 5f472e31..7a5c1437 100644 --- a/components/SummonGrid/index.tsx +++ b/components/SummonGrid/index.tsx @@ -88,6 +88,19 @@ const SummonGrid = (props: Props) => { // Store the important party and state-keeping values appState.party.id = party.id + // Store the party's user-generated details + if (party.name) { + appState.party.name = { + en: party.name.en, + jp: party.name.jp + } + } + if (party.description) + appState.party.description = party.description + + if (party.raid) + appState.raid = party.raid + setFound(true) setLoading(false) diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index 0be9798a..55727517 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -85,6 +85,19 @@ const WeaponGrid = (props: Props) => { appState.party.id = party.id appState.party.extra = party.is_extra + // Store the party's user-generated details + if (party.name) { + appState.party.name = { + en: party.name.en, + jp: party.name.jp + } + } + if (party.description) + appState.party.description = party.description + + if (party.raid) + appState.raid = party.raid + setFound(true) setLoading(false) From c4ec4f76cfd48e263918e0cd2cf92f3ee65c489b Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:13:30 -0800 Subject: [PATCH 05/20] Add endpoint for raids --- utils/api.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/api.tsx b/utils/api.tsx index e1d02c37..4817829a 100644 --- a/utils/api.tsx +++ b/utils/api.tsx @@ -4,7 +4,7 @@ interface Entity { name: string } -type CollectionEndpoint = ({ query }: { query: AxiosRequestConfig }) => Promise> +type CollectionEndpoint = (headers?: {}) => Promise> type IdEndpoint = ({ id }: { id: string }) => Promise> type IdWithObjectEndpoint = ({ id, object }: { id: string, object: string }) => Promise> type PostEndpoint = (object: {}, headers?: {}) => Promise> @@ -41,7 +41,7 @@ class Api { const resourceUrl = `${this.url}/${name}` return { - getAll: ({ query }: { query: AxiosRequestConfig }) => axios.get(resourceUrl, { params: { query }}), + getAll: (headers?: {}) => axios.get(resourceUrl, headers), getOne: ({ id }: { id: string }) => axios.get(`${resourceUrl}/${id}/`), getOneWithObject: ({ id, object }: { id: string, object: string }) => axios.get(`${resourceUrl}/${id}/${object}`), create: (object: {}, headers?: {}) => axios.post(resourceUrl, object, headers), @@ -88,5 +88,6 @@ api.createEntity( { name: 'parties' }) api.createEntity( { name: 'characters' }) api.createEntity( { name: 'weapons' }) api.createEntity( { name: 'summons' }) +api.createEntity( { name: 'raids' }) export default api \ No newline at end of file From 64b26470ac0ef598e3f68c8e5dadff9462972026 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:13:37 -0800 Subject: [PATCH 06/20] Add react-scroll --- package-lock.json | 60 ++++++++++++++++++++++++++++++++++++++++++----- package.json | 2 ++ 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6e89a89d..e8da421c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "react-cookie": "^4.1.1", "react-dom": "^17.0.2", "react-i18next": "^11.15.3", + "react-scroll": "^1.8.5", "sass": "^1.49.0", "valtio": "^1.3.0" }, @@ -33,6 +34,7 @@ "@types/node": "17.0.11", "@types/react": "17.0.38", "@types/react-dom": "^17.0.11", + "@types/react-scroll": "^1.8.3", "eslint": "8.7.0", "eslint-config-next": "12.0.8", "eslint-plugin-valtio": "^0.4.1", @@ -3093,6 +3095,15 @@ "@types/react": "*" } }, + "node_modules/@types/react-scroll": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@types/react-scroll/-/react-scroll-1.8.3.tgz", + "integrity": "sha512-Xt0+Y58pwrIv+vRFxcyKDoo0gBWBR2eNMJ4XRMhQpZdGUtmjnszPi/wFEJSAY+5r83ypJsSA+hOpSc3hRpYlWw==", + "dev": true, + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/scheduler": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", @@ -5330,6 +5341,11 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lodash.throttle": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", + "integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=" + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -5792,7 +5808,6 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -5802,8 +5817,7 @@ "node_modules/prop-types/node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/proxy-compare": { "version": "2.0.2", @@ -5957,6 +5971,19 @@ } } }, + "node_modules/react-scroll": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/react-scroll/-/react-scroll-1.8.5.tgz", + "integrity": "sha512-VcYFWDV2yGeuqeVCt3vxWTGWT4yCcefXOgvNZ16hSD0QTFzNNWiyZKWAVEgmz22PTKJlwRkspALaFI5+cr73OQ==", + "dependencies": { + "lodash.throttle": "^4.1.1", + "prop-types": "^15.7.2" + }, + "peerDependencies": { + "react": "^15.5.4 || ^16.0.0 || ^17.0.0", + "react-dom": "^15.5.4 || ^16.0.0 || ^17.0.0" + } + }, "node_modules/react-style-singleton": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.1.1.tgz", @@ -8943,6 +8970,15 @@ "@types/react": "*" } }, + "@types/react-scroll": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@types/react-scroll/-/react-scroll-1.8.3.tgz", + "integrity": "sha512-Xt0+Y58pwrIv+vRFxcyKDoo0gBWBR2eNMJ4XRMhQpZdGUtmjnszPi/wFEJSAY+5r83ypJsSA+hOpSc3hRpYlWw==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, "@types/scheduler": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", @@ -10594,6 +10630,11 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "lodash.throttle": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", + "integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=" + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -10918,7 +10959,6 @@ "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", - "dev": true, "requires": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -10928,8 +10968,7 @@ "react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" } } }, @@ -11020,6 +11059,15 @@ "tslib": "^1.0.0" } }, + "react-scroll": { + "version": "1.8.5", + "resolved": "https://registry.npmjs.org/react-scroll/-/react-scroll-1.8.5.tgz", + "integrity": "sha512-VcYFWDV2yGeuqeVCt3vxWTGWT4yCcefXOgvNZ16hSD0QTFzNNWiyZKWAVEgmz22PTKJlwRkspALaFI5+cr73OQ==", + "requires": { + "lodash.throttle": "^4.1.1", + "prop-types": "^15.7.2" + } + }, "react-style-singleton": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/react-style-singleton/-/react-style-singleton-2.1.1.tgz", diff --git a/package.json b/package.json index 712aaf27..fa87c27b 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "react-cookie": "^4.1.1", "react-dom": "^17.0.2", "react-i18next": "^11.15.3", + "react-scroll": "^1.8.5", "sass": "^1.49.0", "valtio": "^1.3.0" }, @@ -38,6 +39,7 @@ "@types/node": "17.0.11", "@types/react": "17.0.38", "@types/react-dom": "^17.0.11", + "@types/react-scroll": "^1.8.3", "eslint": "8.7.0", "eslint-config-next": "12.0.8", "eslint-plugin-valtio": "^0.4.1", From f778fd2cf8e8a382bcc030690bbeceb3093181d8 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:13:47 -0800 Subject: [PATCH 07/20] Add element to Raid type --- types/Raid.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/Raid.d.ts b/types/Raid.d.ts index 7512b944..0540c8d6 100644 --- a/types/Raid.d.ts +++ b/types/Raid.d.ts @@ -6,4 +6,5 @@ interface Raid { } level: number group: number + element: TeamElement } \ No newline at end of file From 662062b6222a592c42cfe9bc3908606591514544 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:13:56 -0800 Subject: [PATCH 08/20] Fix arrow SVG --- public/icons/Arrow.svg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/icons/Arrow.svg b/public/icons/Arrow.svg index 29cead04..61369665 100644 --- a/public/icons/Arrow.svg +++ b/public/icons/Arrow.svg @@ -1,3 +1,3 @@ - - + + From f0cf09dc316e5e0b8060e95e44837f6cbec5b28a Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:14:32 -0800 Subject: [PATCH 09/20] Remove user-generated details This goes somewhere else --- components/CharacterGrid/index.tsx | 13 ------------- components/SummonGrid/index.tsx | 13 ------------- components/WeaponGrid/index.tsx | 13 ------------- 3 files changed, 39 deletions(-) diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx index e8b63548..4a1eb463 100644 --- a/components/CharacterGrid/index.tsx +++ b/components/CharacterGrid/index.tsx @@ -78,19 +78,6 @@ const CharacterGrid = (props: Props) => { // Store the important party and state-keeping values appState.party.id = party.id - // Store the party's user-generated details - if (party.name) { - appState.party.name = { - en: party.name.en, - jp: party.name.jp - } - } - if (party.description) - appState.party.description = party.description - - if (party.raid) - appState.raid = party.raid - setFound(true) setLoading(false) diff --git a/components/SummonGrid/index.tsx b/components/SummonGrid/index.tsx index 7a5c1437..5f472e31 100644 --- a/components/SummonGrid/index.tsx +++ b/components/SummonGrid/index.tsx @@ -88,19 +88,6 @@ const SummonGrid = (props: Props) => { // Store the important party and state-keeping values appState.party.id = party.id - // Store the party's user-generated details - if (party.name) { - appState.party.name = { - en: party.name.en, - jp: party.name.jp - } - } - if (party.description) - appState.party.description = party.description - - if (party.raid) - appState.raid = party.raid - setFound(true) setLoading(false) diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index 55727517..0be9798a 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -85,19 +85,6 @@ const WeaponGrid = (props: Props) => { appState.party.id = party.id appState.party.extra = party.is_extra - // Store the party's user-generated details - if (party.name) { - appState.party.name = { - en: party.name.en, - jp: party.name.jp - } - } - if (party.description) - appState.party.description = party.description - - if (party.raid) - appState.raid = party.raid - setFound(true) setLoading(false) From e00a07d10cef0bb76ffc3571c2fc553f6bc77f1d Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:15:08 -0800 Subject: [PATCH 10/20] Various styling fixes and adjustments --- components/Button/index.scss | 4 ++++ components/Party/index.scss | 5 ++++- components/PartySegmentedControl/index.scss | 1 + components/SegmentedControl/index.scss | 1 - components/WeaponGrid/index.scss | 4 ++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/Button/index.scss b/components/Button/index.scss index 666d1800..0b4b88d0 100644 --- a/components/Button/index.scss +++ b/components/Button/index.scss @@ -61,6 +61,10 @@ } } + &.Active { + background: white; + } + &.btn-blue { background: $blue; color: #8b8b8b; diff --git a/components/Party/index.scss b/components/Party/index.scss index 558ffbe9..77ab6f2b 100644 --- a/components/Party/index.scss +++ b/components/Party/index.scss @@ -1,4 +1,7 @@ -.Extra { +#Party { + margin-bottom: $unit * 4; +} +#Party .Extra { color: #888; display: flex; font-weight: 500; diff --git a/components/PartySegmentedControl/index.scss b/components/PartySegmentedControl/index.scss index 96b9f789..a161a3ca 100644 --- a/components/PartySegmentedControl/index.scss +++ b/components/PartySegmentedControl/index.scss @@ -3,6 +3,7 @@ gap: 58px; justify-content: center; margin: 0 auto; + margin-bottom: $unit * 3; max-width: 760px; position: relative; } diff --git a/components/SegmentedControl/index.scss b/components/SegmentedControl/index.scss index 7051099a..2ae75feb 100644 --- a/components/SegmentedControl/index.scss +++ b/components/SegmentedControl/index.scss @@ -1,7 +1,6 @@ .SegmentedControlWrapper { display: flex; justify-content: center; - margin-bottom: $unit * 3; } .SegmentedControl { diff --git a/components/WeaponGrid/index.scss b/components/WeaponGrid/index.scss index 7c37255b..26ea7f7d 100644 --- a/components/WeaponGrid/index.scss +++ b/components/WeaponGrid/index.scss @@ -21,6 +21,10 @@ margin-bottom: $unit * 2; margin-right: $unit * 2; } + + &:nth-last-child(-n+3) { + margin-bottom: 0; + } } .grid_weapons > *:nth-child(3n+3) { From fe14c38fd97c4d4c26afc5121c33f7d462e79e1f Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:15:23 -0800 Subject: [PATCH 11/20] Fix name in state and add detailsVisible flag --- utils/appState.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/utils/appState.tsx b/utils/appState.tsx index d3266802..7b7d8592 100644 --- a/utils/appState.tsx +++ b/utils/appState.tsx @@ -6,10 +6,8 @@ interface AppState { party: { id: string | undefined, editable: boolean, - name: { - en: string, - jp: string - } | undefined, + detailsVisible: boolean, + name: string | undefined, description: string | undefined, raid: Raid | undefined, element: number, @@ -36,6 +34,7 @@ export const initialAppState: AppState = { party: { id: undefined, editable: false, + detailsVisible: false, name: undefined, description: undefined, raid: undefined, From f9857eb77233a69d01e673d75f80a66e9f0f61c7 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 24 Feb 2022 18:18:28 -0800 Subject: [PATCH 12/20] Add components for textareas and text limited fields --- components/CharLimitedFieldset/index.scss | 29 ++++++++++++ components/CharLimitedFieldset/index.tsx | 54 +++++++++++++++++++++++ components/TextFieldset/index.scss | 5 +++ components/TextFieldset/index.tsx | 33 ++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 components/CharLimitedFieldset/index.scss create mode 100644 components/CharLimitedFieldset/index.tsx create mode 100644 components/TextFieldset/index.scss create mode 100644 components/TextFieldset/index.tsx diff --git a/components/CharLimitedFieldset/index.scss b/components/CharLimitedFieldset/index.scss new file mode 100644 index 00000000..5755fd4a --- /dev/null +++ b/components/CharLimitedFieldset/index.scss @@ -0,0 +1,29 @@ +.Limited { + background: white; + border-radius: 6px; + border: 2px solid transparent; + box-sizing: border-box; + display: flex; + gap: $unit; + padding-right: $unit * 2; + + &:focus-within { + border: 2px solid #275DC5; + box-shadow: 0 2px rgba(255, 255, 255, 1); + } + + .Counter { + color: $grey-50; + font-weight: $bold; + line-height: 42px; + } + + .Input { + background: transparent; + border-radius: 0; + + &:focus { + outline: none; + } + } +} \ No newline at end of file diff --git a/components/CharLimitedFieldset/index.tsx b/components/CharLimitedFieldset/index.tsx new file mode 100644 index 00000000..aefd8ab6 --- /dev/null +++ b/components/CharLimitedFieldset/index.tsx @@ -0,0 +1,54 @@ +import React, { useEffect, useState } from 'react' +import './index.scss' + +interface Props { + fieldName: string + placeholder: string + value?: string + limit: number + error: string + onBlur?: (event: React.ChangeEvent) => void + onChange?: (event: React.ChangeEvent) => void +} + +const CharLimitedFieldset = React.forwardRef(function fieldSet(props, ref) { + const fieldType = (['password', 'confirm_password'].includes(props.fieldName)) ? 'password' : 'text' + + const [currentCount, setCurrentCount] = useState(0) + + useEffect(() => { + setCurrentCount((props.value) ? props.limit - props.value.length : props.limit) + }, [props.limit, props.value]) + + function onChange(event: React.ChangeEvent) { + setCurrentCount(props.limit - event.currentTarget.value.length) + if (props.onChange) props.onChange(event) + } + + return ( +
+
+ + {currentCount} +
+ { + props.error.length > 0 && +

{props.error}

+ } + + ) +}) + +export default CharLimitedFieldset \ No newline at end of file diff --git a/components/TextFieldset/index.scss b/components/TextFieldset/index.scss new file mode 100644 index 00000000..f84fe540 --- /dev/null +++ b/components/TextFieldset/index.scss @@ -0,0 +1,5 @@ +.Fieldset textarea { + color: $grey-00; + font-family: system-ui, -apple-system, 'Helvetica Neue', Helvetica, Arial, sans-serif; + line-height: 21px; +} \ No newline at end of file diff --git a/components/TextFieldset/index.tsx b/components/TextFieldset/index.tsx new file mode 100644 index 00000000..63b80c61 --- /dev/null +++ b/components/TextFieldset/index.tsx @@ -0,0 +1,33 @@ +import React from 'react' +import './index.scss' + +interface Props { + fieldName: string + placeholder: string + value?: string + error: string + onBlur?: (event: React.ChangeEvent) => void + onChange?: (event: React.ChangeEvent) => void +} + +const TextFieldset = React.forwardRef(function fieldSet(props, ref) { + return ( +
+