-
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.
Adicionado novo estilo do input (#169)
* added new input style * fix defaultValue input mask
- Loading branch information
Showing
2 changed files
with
155 additions
and
79 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,83 +1,101 @@ | ||
import styled from 'styled-components'; | ||
import { getTheme, ifStyle } from '@platformbuilders/theme-toolkit'; | ||
import { getTheme, ifStyle, pxToRem } from '@platformbuilders/theme-toolkit'; | ||
|
||
type HasIcon = { | ||
hasIconLeft?: boolean; | ||
hasIconRight?: boolean; | ||
}; | ||
|
||
type PlaceholderLabelProps = { | ||
$hasValue: boolean; | ||
$hasError: boolean; | ||
}; | ||
} & HasIcon; | ||
|
||
type MessageProps = { | ||
$hasError: boolean; | ||
}; | ||
|
||
type InputProps = { | ||
$hasError: boolean; | ||
}; | ||
} & HasIcon; | ||
|
||
const primaryMain = getTheme('brand.primary.main'); | ||
const dangerMain = getTheme('danger.main'); | ||
const textMain = getTheme('danger.main'); | ||
const fontSizeSm = getTheme('fontSizes.sm'); | ||
const fontSizeMd = getTheme('fontSizes.md'); | ||
const spacingXs = getTheme('spacing.xs'); | ||
const spacingSm = getTheme('spacing.sm'); | ||
const spacingMd = getTheme('spacing.md'); | ||
const spacingLg = getTheme('spacing.lg'); | ||
const textMain = getTheme('text.main'); | ||
const borderRadiusMd = getTheme('borderRadius.md'); | ||
|
||
const hasError = ifStyle('$hasError'); | ||
|
||
export const PlaceholderLabel = styled.span<PlaceholderLabelProps>` | ||
position: absolute; | ||
top: 0.9375rem; | ||
left: 0.875rem; | ||
top: ${pxToRem(16)}; | ||
left: ${pxToRem(14)}; | ||
line-height: 147.6%; | ||
color: rgba(19, 19, 21, 0.6); | ||
transition: top 0.2s; | ||
${({ hasIconLeft }) => !!hasIconLeft && `left: ${pxToRem(36)};`} | ||
${(props) => | ||
props.$hasValue && | ||
`top: 0; font-size: 0.9375rem; margin-bottom: 40px; color: ${primaryMain( | ||
props, | ||
)};`} | ||
props.$hasValue && `top: 0; font-size: ${fontSizeMd}; margin-bottom: 40px;`} | ||
color: ${(props) => hasError(dangerMain(props), primaryMain(props))(props)}; | ||
`; | ||
|
||
export const Input = styled.input<InputProps>` | ||
border: none; | ||
border-bottom: 0.125rem solid rgba(19, 19, 21, 0.6); | ||
width: 100%; | ||
height: 3.5rem; | ||
font-size: 1.0625rem; | ||
padding-left: 0.875rem; | ||
font-size: ${fontSizeMd}px; | ||
line-height: 147.6%; | ||
padding-top: 0.825rem; | ||
padding-bottom: 0.5rem; | ||
border-color: ${(props) => hasError(dangerMain(props), '#121212')(props)}; | ||
&:hover { | ||
background: rgba(73, 133, 224, 0.12); | ||
} | ||
display: flex; | ||
height: ${pxToRem(44)}; | ||
padding: ${spacingXs}px ${spacingSm}px ${spacingXs}px ${spacingMd}px; | ||
${({ hasIconRight }) => !!hasIconRight && `padding-right: ${pxToRem(36)};`} | ||
${({ hasIconLeft }) => !!hasIconLeft && `padding-left: ${pxToRem(36)};`} | ||
align-items: center; | ||
gap: ${pxToRem(12)}; | ||
background: ${(props) => | ||
!!props.$hasError ? `${dangerMain(props)}10` : `${textMain(props)}10`}; | ||
border-radius: ${borderRadiusMd}px; | ||
border: none; | ||
font-size: ${fontSizeSm}px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 150%; | ||
&:focus { | ||
border-color: ${(props) => | ||
hasError(dangerMain(props), primaryMain(props))(props)}; | ||
outline: none; | ||
} | ||
&:focus + ${PlaceholderLabel} { | ||
top: 0; | ||
font-size: 0.9375rem; | ||
margin-bottom: 40px; | ||
color: ${(props) => hasError(dangerMain(props), primaryMain(props))(props)}; | ||
} | ||
background: #eff1f2; | ||
`; | ||
|
||
export const Message = styled.span<MessageProps>` | ||
font-size: 0.9375rem; | ||
font-size: ${fontSizeMd}px; | ||
color: ${(props) => hasError(dangerMain(props), textMain(props))(props)}; | ||
letter-spacing: 0.0275rem; | ||
margin: 0.125rem 0.875rem; | ||
margin: ${spacingXs}px ${spacingMd}px; | ||
`; | ||
|
||
export const Label = styled.label``; | ||
|
||
export const Wrapper = styled.div` | ||
margin-bottom: 1.5rem; | ||
margin-bottom: ${spacingLg}px; | ||
position: relative; | ||
`; | ||
|
||
export const IconWrapperLeft = styled.div<{ clickable?: boolean }>` | ||
position: absolute; | ||
left: ${pxToRem(14)}; | ||
top: ${pxToRem(22)}; | ||
transform: translateY(-50%); | ||
cursor: ${({ clickable }) => (!!clickable ? 'pointer' : 'default')}; | ||
`; | ||
|
||
export const IconWrapperRight = styled.div<{ clickable?: boolean }>` | ||
position: absolute; | ||
right: ${pxToRem(14)}; | ||
top: ${pxToRem(22)}; | ||
transform: translateY(-50%); | ||
cursor: ${({ clickable }) => (!!clickable ? 'pointer' : 'default')}; | ||
`; |