Merged in chore/SW-3356-move-textarea-from-tempds-to-ds (pull request #2745)
chore(SW-3356): Moved TextArea to design system * chore(SW-3356): Moved TextArea to design system Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import TextArea from "@scandic-hotels/design-system/Form/TextArea"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
|
||||
import TextArea from "@/components/TempDesignSystem/Form/TextArea"
|
||||
|
||||
import styles from "./specialRequests.module.css"
|
||||
|
||||
import type { RegisterOptions } from "react-hook-form"
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
"use client"
|
||||
'use client'
|
||||
|
||||
import {
|
||||
Label as AriaLabel,
|
||||
Text,
|
||||
TextArea as AriaTextArea,
|
||||
TextField,
|
||||
} from "react-aria-components"
|
||||
import { Controller, useFormContext } from "react-hook-form"
|
||||
} from 'react-aria-components'
|
||||
import { Controller, useFormContext } from 'react-hook-form'
|
||||
|
||||
import Body from "@scandic-hotels/design-system/Body"
|
||||
import Caption from "@scandic-hotels/design-system/Caption"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Label } from "@scandic-hotels/design-system/Label"
|
||||
import { MaterialIcon } from '../../Icons/MaterialIcon'
|
||||
import { Label } from '../../Label'
|
||||
import { Typography } from '../../Typography'
|
||||
|
||||
import styles from "./textarea.module.css"
|
||||
import styles from './textarea.module.css'
|
||||
|
||||
import type { TextAreaProps } from "./input"
|
||||
import type { TextAreaProps } from './input'
|
||||
|
||||
export default function TextArea({
|
||||
"aria-label": ariaLabel,
|
||||
className = "",
|
||||
'aria-label': ariaLabel,
|
||||
className = '',
|
||||
disabled = false,
|
||||
helpText = "",
|
||||
helpText = '',
|
||||
label,
|
||||
name,
|
||||
placeholder = "",
|
||||
placeholder = '',
|
||||
readOnly = false,
|
||||
registerOptions = {},
|
||||
}: TextAreaProps) {
|
||||
@@ -48,7 +47,7 @@ export default function TextArea({
|
||||
value={field.value}
|
||||
>
|
||||
<AriaLabel className={styles.container}>
|
||||
<Body asChild fontOnly>
|
||||
<Typography variant="Body/Paragraph/mdRegular">
|
||||
<AriaTextArea
|
||||
{...field}
|
||||
aria-labelledby={field.name}
|
||||
@@ -57,22 +56,24 @@ export default function TextArea({
|
||||
required={!!registerOptions.required}
|
||||
className={styles.textarea}
|
||||
/>
|
||||
</Body>
|
||||
</Typography>
|
||||
<Label required={!!registerOptions.required}>{label}</Label>
|
||||
</AriaLabel>
|
||||
{helpText && !fieldState.error ? (
|
||||
<Caption asChild color="black">
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<Text className={styles.helpText} slot="description">
|
||||
<MaterialIcon icon="check" size={30} />
|
||||
{helpText}
|
||||
</Text>
|
||||
</Caption>
|
||||
</Typography>
|
||||
) : null}
|
||||
{fieldState.error ? (
|
||||
<Caption className={styles.error} fontOnly>
|
||||
<MaterialIcon icon="info" color="Icon/Interactive/Accent" />
|
||||
{fieldState.error.message}
|
||||
</Caption>
|
||||
<Typography variant="Body/Supporting text (caption)/smRegular">
|
||||
<p className={styles.error}>
|
||||
<MaterialIcon icon="info" color="Icon/Interactive/Accent" />
|
||||
{fieldState.error.message}
|
||||
</p>
|
||||
</Typography>
|
||||
) : null}
|
||||
</TextField>
|
||||
)}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { RegisterOptions } from "react-hook-form"
|
||||
import type { RegisterOptions } from 'react-hook-form'
|
||||
|
||||
export interface TextAreaProps
|
||||
extends React.InputHTMLAttributes<HTMLTextAreaElement> {
|
||||
@@ -36,7 +36,7 @@
|
||||
color: var(--Main-Grey-40);
|
||||
}
|
||||
|
||||
.container:has(.textarea[data-invalid="true"], .textarea[aria-invalid="true"]) {
|
||||
.container:has(.textarea[data-invalid='true'], .textarea[aria-invalid='true']) {
|
||||
border-color: var(--Scandic-Red-60);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
"./Form/ErrorMessage": "./lib/components/Form/ErrorMessage/index.tsx",
|
||||
"./Form/Phone": "./lib/components/Form/Phone/index.tsx",
|
||||
"./Form/RadioCard": "./lib/components/Form/RadioCard/index.tsx",
|
||||
"./Form/TextArea": "./lib/components/Form/TextArea/index.tsx",
|
||||
"./HotelInfoCard": "./lib/components/HotelInfoCard/index.tsx",
|
||||
"./HotelCard": "./lib/components/HotelCard/index.tsx",
|
||||
"./HotelCard/HotelCardDialogImage": "./lib/components/HotelCard/HotelCardDialogImage/index.tsx",
|
||||
|
||||
Reference in New Issue
Block a user