-
Notifications
You must be signed in to change notification settings - Fork 21
[BOOKINGSG-9308][IT] Migrate uneditable section component #1179
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
base: pre-release/v4
Are you sure you want to change the base?
Changes from all commits
5e23e71
13f3197
f96c7a0
da38fae
b330159
9e5b022
607ce9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| "use client"; | ||
|
|
||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
| import { items } from "./uneditable-section-shared"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container story-background"> | ||
| <UneditableSection | ||
| data-testid="uneditable-section-full-width" | ||
| title="Personal Information" | ||
| description="Sample description" | ||
| items={items} | ||
| fullWidth | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| "use client"; | ||
|
|
||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
| import { items } from "./uneditable-section-shared"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container story-background"> | ||
| <UneditableSection | ||
| data-testid="uneditable-section" | ||
| title="Personal Information" | ||
| description="Sample description" | ||
| items={items} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| "use client"; | ||
|
|
||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
| import { items } from "./uneditable-section-shared"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container story-background"> | ||
| <UneditableSection | ||
| data-testid="uneditable-section" | ||
| title="Personal Information" | ||
| description="Sample description" | ||
| items={items} | ||
| background={false} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| "use client"; | ||
|
|
||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <UneditableSection | ||
| data-testid="uneditable-section" | ||
| title="Personal Information" | ||
| items={[ | ||
| { | ||
| label: "Error and alert variant", | ||
| value: "S1234534J", | ||
| maskState: "masked", | ||
| maskRange: [1, 4], | ||
| maskLoadingState: "fail", | ||
| displayWidth: "half", | ||
| alert: { | ||
| children: "Sample alert message", | ||
| type: "warning", | ||
| }, | ||
| }, | ||
| ]} | ||
| /> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| "use client"; | ||
|
|
||
| import { Alert } from "@lifesg/react-design-system/alert"; | ||
| import { Button } from "@lifesg/react-design-system/button"; | ||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
| import styles from "./full-custom-sections.module.css"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <UneditableSection> | ||
| <div className={styles["custom-style-1"]}> | ||
| <div className={styles["custom-style-2"]}> | ||
| <h3>My custom content</h3> | ||
| <Button styleType="light">Custom button</Button> | ||
| </div> | ||
| <div className={styles["custom-style-3"]}> | ||
| <Alert type="warning">Custom alert</Alert> | ||
| </div> | ||
| <p className={styles["custom-style-3"]}> | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
| Etiam pellentesque enim eu neque gravida, ut pulvinar magna | ||
| tristique. Aenean sed malesuada arcu. Integer convallis | ||
| dapibus suscipit. | ||
| </p> | ||
| <UneditableSection.ItemSection> | ||
| <UneditableSection.Item | ||
| displayWidth="half" | ||
| label="Name (as in NRIC or passport)" | ||
| value="Tom Tan Li Ho" | ||
| /> | ||
| <UneditableSection.Item | ||
| displayWidth="half" | ||
| label="NRIC or FIN" | ||
| value="S••••534J" | ||
| /> | ||
| <UneditableSection.Item | ||
| label="Residential Address" | ||
| value="Block 287, #05-11, Tampines street 22, Singapore 534788" | ||
| /> | ||
| </UneditableSection.ItemSection> | ||
| <h3 className={styles["custom-style-2"]}>Another section</h3> | ||
| <UneditableSection.ItemSection> | ||
| <UneditableSection.Item | ||
| label="Custom content list" | ||
| value={ | ||
| <ul> | ||
| <li>Option 1</li> | ||
| <li>Option 2</li> | ||
| <li>Option 3</li> | ||
| </ul> | ||
| } | ||
| /> | ||
| </UneditableSection.ItemSection> | ||
| </div> | ||
| </UneditableSection> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| .custom-style-1 { | ||
| display: flex; | ||
| flex-direction: column; | ||
| grid-column: span 8; | ||
| } | ||
|
|
||
| .custom-style-2 { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| margin-bottom: 2rem; | ||
| } | ||
|
|
||
| .custom-style-3 { | ||
| margin-bottom: 1rem; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| "use client"; | ||
|
|
||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <UneditableSection | ||
| data-testid="uneditable-section" | ||
| title="Personal Information" | ||
| items={[ | ||
| { | ||
| label: "Loading variant", | ||
| value: "S1234534J", | ||
| maskState: "masked", | ||
| maskRange: [1, 4], | ||
| maskLoadingState: "loading", | ||
| displayWidth: "half", | ||
| }, | ||
| ]} | ||
| /> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| "use client"; | ||
|
|
||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container story-background"> | ||
| <UneditableSection | ||
| data-testid="uneditable-section-full-width" | ||
| title="Personal Information" | ||
| description="Sample description" | ||
| items={[ | ||
| { | ||
| displayWidth: "half", | ||
| label: "Plain text", | ||
| value: "S1234567D", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "With mask range", | ||
| maskRange: [1, 4], | ||
| maskState: "masked", | ||
| value: "S1234567D", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "With mask range (start only)", | ||
| maskRange: [4, 9999], | ||
| maskState: "masked", | ||
| value: "S1234567D", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "With mask range (end only)", | ||
| maskRange: [0, 4], | ||
| maskState: "masked", | ||
| value: "S1234567D", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "With unmask range", | ||
| maskState: "masked", | ||
| unmaskRange: [1, 4], | ||
| value: "S1234567D", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "With mask regex", | ||
| maskRegex: /\D/g, | ||
| maskState: "masked", | ||
| value: "S1234567D", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "With mask transformer (X)", | ||
| maskState: "masked", | ||
| maskTransformer: (value) => value.replace(/\d/g, "X"), | ||
| value: "S1234567D", | ||
| }, | ||
| { | ||
| disableMaskUnmask: true, | ||
| displayWidth: "half", | ||
| label: "With mask range but disabled unmasking", | ||
| maskRange: [1, 4], | ||
| maskState: "masked", | ||
| value: "S1234567D", | ||
| }, | ||
| ]} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| "use client"; | ||
|
|
||
| import { UneditableSection } from "@lifesg/react-design-system/uneditable-section"; | ||
| import { Alert } from "@lifesg/react-design-system/alert"; | ||
| import { Button } from "@lifesg/react-design-system/button"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <UneditableSection | ||
| data-testid="uneditable-section" | ||
| title="Personal Information" | ||
| description="Your personal details with additional sections" | ||
| topSection={ | ||
| <Alert type="info" data-testid="top-section-alert"> | ||
| Custom alert section | ||
| </Alert> | ||
| } | ||
| items={[ | ||
| { | ||
| label: "Name (as in NRIC or passport)", | ||
| value: "Tom Tan Li Ho", | ||
| displayWidth: "half", | ||
| }, | ||
| { | ||
| label: "NRIC or FIN", | ||
| value: "S1234534J", | ||
| displayWidth: "half", | ||
| }, | ||
| { | ||
| label: "Date of birth", | ||
| value: "6 November 1992", | ||
| displayWidth: "half", | ||
| }, | ||
| { | ||
| label: "Nationality", | ||
| value: "Singaporean", | ||
| displayWidth: "half", | ||
| }, | ||
| ]} | ||
| bottomSection={ | ||
| <div data-testid="bottom-section-actions"> | ||
| <Button>Custom button</Button> | ||
| </div> | ||
| } | ||
| /> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { UneditableSectionItemProps } from "@lifesg/react-design-system/uneditable-section"; | ||
|
|
||
| export const items: UneditableSectionItemProps[] = [ | ||
| { | ||
| displayWidth: "half", | ||
| label: "Name (as in NRIC or passport)", | ||
| value: "Tom Tan Li Ho", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "NRIC or FIN", | ||
| maskRange: [1, 4], | ||
| maskState: "masked", | ||
| value: "S1234534J", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "Date of birth", | ||
| value: "6 November 1992", | ||
| }, | ||
| { | ||
| displayWidth: "half", | ||
| label: "Residential Address", | ||
| value: "Block 287, #05-11, Tampines Street 22, Singapore 534788", | ||
| }, | ||
| { | ||
| label: "Ethnicity", | ||
| value: "Chinese", | ||
| }, | ||
| ]; |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we include a mobile screenshot of this? |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm this doesn't look right, it's supposed to switch to 1 column view on mobile |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets not include loading into the cases as the animation makes it unstable
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can still include loading, should be alright since this is a css animation, and playwright pauses it accordingly. but the timer manipulation needs to be consistent. link-list did something similar, can reference that |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ehhhh we don't probably don't need ALL masked variants since a lot of this is programmatic, and doesn't have a visual difference just check if they are covered in the unit tests, if not, add the scenarios there. remove from the e2e test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a border to indicate the custom sections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this is meant to be deleted and we're using the
Partial-customone