-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 Correção do componente de Fildset
- Loading branch information
Showing
9 changed files
with
377 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,73 @@ | ||
import styled from "styled-components"; | ||
import styled, { css } from "styled-components"; | ||
|
||
export const Fieldset = styled.fieldset<{ | ||
width?: string; | ||
height?: string; | ||
export const FieldSetContent = styled.div` | ||
overflow: scroll; | ||
width: 100%; | ||
word-wrap: break-word; | ||
`; | ||
|
||
export const Fieldset = styled.div<{ | ||
color?: string; | ||
$hasOverflow?: boolean; | ||
$justifyContent?: "start" | "center" | "end"; | ||
}>` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
justify-content: ${({ $justifyContent }) => $justifyContent || "center"}; | ||
padding: 16px; | ||
width: ${({ width }) => width || "fit-content"}; | ||
height: ${({ height }) => height || "fit-content"}; | ||
border-radius: 4px; | ||
border: 1px solid ${({ theme, color }) => color || theme.colors.neutral["15"]}; | ||
text-overflow: ellipsis; | ||
line-height: 112%; | ||
overflow: ${({ $hasOverflow }) => ($hasOverflow ? "scroll" : "hidden")}; | ||
border: 1px solid ${({ theme, color }) => color ?? theme.colors.neutral["15"]}; | ||
line-height: 132%; | ||
color: ${({ theme }) => theme.colors.neutral["100"]}; | ||
`; | ||
padding: 1rem; | ||
width: 100%; | ||
overflow: hidden; | ||
export const Legend = styled.legend` | ||
padding: 0px 4px 0px 4px; | ||
${({ $hasOverflow }) => | ||
!$hasOverflow && | ||
css` | ||
${FieldSetContent} { | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
} | ||
`}; | ||
`; | ||
|
||
export const LegendText = styled.span` | ||
export const Legend = styled.span` | ||
font-style: normal; | ||
font-weight: 400; | ||
font-size: 12px; | ||
font-size: 1rem; | ||
line-height: 16px; | ||
letter-spacing: 0.4px; | ||
color: #2b4417; | ||
flex: none; | ||
order: 0; | ||
flex-grow: 0; | ||
background-color: #f8fcf6; | ||
display: inline-flex; | ||
left: 16px; | ||
padding: 0px 4px; | ||
top: 8px; | ||
position: relative; | ||
`; | ||
|
||
export const FieldsetTextContent = styled.p` | ||
width: 100%; | ||
height: fit-content; | ||
`; | ||
|
||
export const FieldsetContainer = styled.div<{ | ||
width?: string; | ||
height?: string; | ||
$hasOverflow?: boolean; | ||
}>` | ||
width: ${({ width }) => width ?? "fit-content"}; | ||
height: fit-content; | ||
${Fieldset} { | ||
max-height: ${({ height }) => height ?? "51px"}; | ||
} | ||
${FieldSetContent} { | ||
${({ $hasOverflow, height }) => | ||
$hasOverflow && | ||
height && | ||
css` | ||
height: ${height}; | ||
`} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,65 @@ | ||
import { ChangeEventHandler, ReactNode } from "react"; | ||
import { SelectComponent, CustomOption } from "./styles"; | ||
import { CustomFieldset } from "@/components/Fieldset"; | ||
|
||
interface OptionProps { | ||
key: string; | ||
value: string; | ||
text: string; | ||
isDisabled?: boolean; | ||
isSelected?: boolean; | ||
} | ||
|
||
interface SelectProps { | ||
labelText: string; | ||
width?: string; | ||
placeholder?: string; | ||
height?: string; | ||
onChange?: ChangeEventHandler<HTMLSelectElement>; | ||
options?: OptionProps[]; | ||
isRequired?: boolean; | ||
multiple?: boolean; | ||
form?: string; | ||
name?: string; | ||
value?: string; | ||
} | ||
|
||
export const CustomSelect = ({ | ||
labelText, | ||
placeholder = "selecione uma opção", | ||
width = "100%", | ||
height = "56px", | ||
options, | ||
onChange, | ||
isRequired = false, | ||
multiple = false, | ||
form | ||
}: SelectProps) => { | ||
return ( | ||
<CustomFieldset width={width} height={height} labelText={labelText}> | ||
<SelectComponent | ||
onChange={onChange} | ||
required={isRequired} | ||
name={placeholder} | ||
multiple={multiple} | ||
form={form} | ||
defaultValue={placeholder}> | ||
<CustomOption value=""> | ||
{placeholder ?? "selecione uma opção abaixo"} | ||
</CustomOption> | ||
{options?.map((option) => ( | ||
<CustomOption | ||
key={option?.key} | ||
value={option?.value} | ||
selected={option?.isSelected as boolean} | ||
disabled={option?.isDisabled as boolean}> | ||
{option?.text} | ||
</CustomOption> | ||
))} | ||
</SelectComponent> | ||
</CustomFieldset> | ||
); | ||
}; | ||
import { ChangeEventHandler, ReactNode } from "react"; | ||
import { SelectComponent, CustomOption } from "./styles"; | ||
import { CustomFieldset } from "@/components/Fieldset"; | ||
|
||
interface OptionProps { | ||
key: string; | ||
value: string; | ||
text: string; | ||
isDisabled?: boolean; | ||
isSelected?: boolean; | ||
} | ||
|
||
interface SelectProps { | ||
labelText: string; | ||
width?: string; | ||
placeholder?: string; | ||
height?: string; | ||
onChange?: ChangeEventHandler<HTMLSelectElement>; | ||
options?: OptionProps[]; | ||
isRequired?: boolean; | ||
multiple?: boolean; | ||
form?: string; | ||
name?: string; | ||
value?: string; | ||
} | ||
|
||
export const CustomSelect = ({ | ||
labelText, | ||
placeholder = "selecione uma opção", | ||
width = "100%", | ||
height = "56px", | ||
options, | ||
onChange, | ||
isRequired = false, | ||
multiple = false, | ||
form | ||
}: SelectProps) => { | ||
return ( | ||
<CustomFieldset | ||
width={width} | ||
height={height} | ||
labelText={labelText}> | ||
<SelectComponent | ||
onChange={onChange} | ||
required={isRequired} | ||
name={placeholder} | ||
multiple={multiple} | ||
form={form} | ||
defaultValue={placeholder}> | ||
<CustomOption value=""> | ||
{placeholder ?? "selecione uma opção abaixo"} | ||
</CustomOption> | ||
{options?.map((option) => ( | ||
<CustomOption | ||
key={option?.key} | ||
value={option?.value} | ||
selected={option?.isSelected as boolean} | ||
disabled={option?.isDisabled as boolean}> | ||
{option?.text} | ||
</CustomOption> | ||
))} | ||
</SelectComponent> | ||
</CustomFieldset> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
import styled from "styled-components"; | ||
|
||
export const SelectContainer = styled.div<{ $status: string }>` | ||
width: inherit; | ||
display: flex; | ||
& > fieldset { | ||
padding: 11px 12px; | ||
border: ${({ $status }) => | ||
$status === "invalid" | ||
? "1px solid red" | ||
: $status === "valid" | ||
? "1px solid #7ac143" | ||
: "1px solid #79747e"}; | ||
} | ||
`; | ||
|
||
export const SelectComponent = styled.select` | ||
display: flex; | ||
width: 100%; | ||
height: 100%; | ||
outline: 0; | ||
border: none; | ||
font-weight: 400; | ||
font-size: 1rem; | ||
line-height: 24px; | ||
align-items: center; | ||
justify-content: center; | ||
margin-bottom: 7px; | ||
letter-spacing: 0.5px; | ||
resize: none; | ||
background: transparent; | ||
color: #77757b; | ||
`; | ||
|
||
export const CustomOption = styled.option` | ||
display: flex; | ||
align-items: center; | ||
background-color: #ebf6e3; | ||
padding-bottom: 10px; | ||
width: 20px; | ||
border-radius: 0; | ||
border: none; | ||
font-size: 16px; | ||
`; | ||
import styled from "styled-components"; | ||
|
||
export const SelectContainer = styled.div<{ $status: string }>` | ||
width: inherit; | ||
display: flex; | ||
& > div > div { | ||
border: ${({ $status }) => | ||
$status === "invalid" | ||
? "1px solid red" | ||
: $status === "valid" | ||
? "1px solid #7ac143" | ||
: "1px solid #79747e"}; | ||
} | ||
`; | ||
|
||
export const SelectComponent = styled.select` | ||
display: flex; | ||
width: 100%; | ||
height: 100%; | ||
outline: 0; | ||
border: none; | ||
font-weight: 400; | ||
font-size: 1rem; | ||
line-height: 24px; | ||
align-items: center; | ||
justify-content: center; | ||
letter-spacing: 0.5px; | ||
resize: none; | ||
background: transparent; | ||
`; | ||
|
||
export const CustomOption = styled.option` | ||
display: flex; | ||
align-items: center; | ||
background-color: #ebf6e3; | ||
padding-bottom: 10px; | ||
width: 20px; | ||
border-radius: 0; | ||
border: none; | ||
font-size: 16px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.