Skip to content

Commit 6fc3fe4

Browse files
authored
feat: added data ids for input fields (#486)
* feat: added data ids for input fields * fix: fixed asterisk position in labels * fix: fixed data ids for inputs
1 parent 0a54be9 commit 6fc3fe4

File tree

18 files changed

+63
-7
lines changed

18 files changed

+63
-7
lines changed

apps/site/src/demos/DropdownInputDemo.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ const DropdownInputDemo = () => {
289289
<div className="min-h-32 rounded-2xl w-full flex justify-center items-center outline-1 outline-gray-200 bg-gray-50 p-8">
290290
<div className="w-full max-w-md">
291291
<DropdownInput
292+
data-id={'Enter city name'}
293+
data-input-name={playgroundValue}
294+
name={playgroundValue}
292295
dropdownPosition={DropdownPosition.LEFT}
293296
// slot={<User size={12} />}
294297
onBlur={() => {

apps/site/src/demos/NumberInputDemo.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ const NumberInputDemo = () => {
6060
<div className="space-y-6">
6161
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
6262
<NumberInput
63+
data-id={'Enter value'}
64+
data-input-name={playgroundValue?.toString() || ''}
65+
name={playgroundValue?.toString() || ''}
6366
label="Value"
6467
value={playgroundValue}
6568
onChange={(e) =>

apps/site/src/demos/OTPInputDemo.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,12 @@ const OTPInputDemo = () => {
130130
<div className="min-h-40 rounded-2xl w-full flex justify-center items-center outline-1 outline-gray-200 p-8">
131131
<div className="w-full max-w-md">
132132
<OTPInput
133+
data-id={'Enter OTP Code'}
134+
data-input-name={playgroundValue}
135+
name={playgroundValue}
133136
label={playgroundLabel}
134137
sublabel={playgroundSublabel}
138+
placeholder={'otp field'}
135139
value={playgroundValue}
136140
length={playgroundLength}
137141
autoFocus={hasAutoFocus}
@@ -149,7 +153,6 @@ const OTPInputDemo = () => {
149153
hintText={playgroundHintText}
150154
helpIconHintText={playgroundHelpText}
151155
required={isRequired}
152-
name="playground-otp"
153156
onKeyDown={(e) => {
154157
console.log('onKeyDown', e)
155158
}}

apps/site/src/demos/SearchInputDemo.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ const SearchInputDemo = () => {
130130
<div className="min-h-40 rounded-2xl w-full flex justify-center items-center outline-1 outline-gray-200 p-8">
131131
<div className="w-full max-w-md">
132132
<SearchInput
133+
data-id={'Enter search query'}
134+
data-input-name={playgroundValue}
135+
name={playgroundValue}
133136
value={playgroundValue}
134137
onChange={(e) =>
135138
setPlaygroundValue(e.target.value)

apps/site/src/demos/TextInputDemo.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ const InputDemo = () => {
126126
<div className="min-h-40 rounded-2xl w-full flex justify-center items-center outline-1 outline-gray-200 p-8">
127127
<div className="w-full max-w-md">
128128
<TextInput
129+
data-id={'Enter text here...'}
130+
data-input-name={playgroundText}
131+
name={playgroundText}
129132
label={playgroundText}
130133
value={playgroundValue}
131134
onChange={(e) =>

apps/site/src/demos/UnitInputDemo.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ const UnitInputDemo = () => {
205205
<h3>Preview</h3>
206206
<div style={{ maxWidth: '400px' }}>
207207
<UnitInput
208+
data-id={'Enter value'}
209+
data-input-name={
210+
playgroundValue?.toString() || ''
211+
}
212+
name={playgroundValue?.toString() || ''}
208213
value={playgroundValue}
209214
onChange={(e) => {
210215
const newValue = parseFloat(e.target.value)
@@ -243,7 +248,6 @@ const UnitInputDemo = () => {
243248
? getRightSlotIcon()
244249
: undefined
245250
}
246-
name="playground-unit-input"
247251
/>
248252
</div>
249253
</div>

packages/blend/lib/components/Alert/Alert.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const Alert = forwardRef<HTMLDivElement, AlertProps>(
7474
</Block>
7575
)}
7676
<Text
77+
data-alert-heading={heading}
7778
color={alertTokens.text.heading.color[variant]}
7879
fontWeight={alertTokens.text.heading.fontWeight}
7980
fontSize={alertTokens.text.heading.fontSize}
@@ -112,6 +113,7 @@ const Alert = forwardRef<HTMLDivElement, AlertProps>(
112113
gap={FOUNDATION_THEME.unit[18]}
113114
>
114115
<Text
116+
data-alert-description={description}
115117
fontWeight={alertTokens.text.description.fontWeight}
116118
fontSize={alertTokens.text.description.fontSize}
117119
lineHeight={alertTokens.text.description.lineHeight}

packages/blend/lib/components/Inputs/MultiValueInput/MultiValueInput.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ const MultiValueInput = ({
6767
const paddingX = multiValueInputTokens.inputContainer.padding.x[size]
6868
const paddingY = multiValueInputTokens.inputContainer.padding.y[size]
6969
return (
70-
<Block display="flex" flexDirection="column" gap={8}>
70+
<Block
71+
data-component-field-wrapper={`field-multi-value-input`}
72+
display="flex"
73+
flexDirection="column"
74+
gap={8}
75+
>
7176
<InputLabels
7277
label={label}
7378
sublabel={sublabel}

packages/blend/lib/components/Inputs/NumberInput/NumberInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const NumberInput = ({
5353

5454
return (
5555
<Block
56+
data-component-field-wrapper={`field-${name}`}
5657
display="flex"
5758
flexDirection="column"
5859
gap={numberInputTokens.gap}

packages/blend/lib/components/Inputs/OTPInput/OTPInput.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { useResponsiveTokens } from '../../../hooks/useResponsiveTokens'
1616

1717
const OTPInput = ({
1818
label,
19+
placeholder,
1920
sublabel,
2021
disabled,
2122
helpIconHintText,
@@ -144,6 +145,7 @@ const OTPInput = ({
144145

145146
return (
146147
<Block
148+
data-component={'otp-input'}
147149
display="flex"
148150
flexDirection="column"
149151
gap={otpInputTokens.gap}
@@ -165,6 +167,8 @@ const OTPInput = ({
165167
>
166168
{otp.map((digit, index) => (
167169
<PrimitiveInput
170+
placeholder={placeholder}
171+
placeholderColor={'transparent'}
168172
form={form}
169173
width={otpInputTokens.inputContainer.input.width}
170174
height={otpInputTokens.inputContainer.input.height}

0 commit comments

Comments
 (0)