-
Notifications
You must be signed in to change notification settings - Fork 1
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
Docs(web, web-twig, web-react): Extend TextField
s README.md about missing section inputWidth
#1269
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -42,6 +42,52 @@ TextField with password toggle (button to reveal the password): | |
/> | ||
``` | ||
|
||
## Input Width | ||
|
||
There are several ways to adjust the input width: | ||
|
||
### `inputWidth` Attribute | ||
|
||
The `inputWidth` attribute is supported on inputs of the following types: `email`, | ||
`password`, `tel`, `text`, `url`. | ||
|
||
```jsx | ||
<TextField | ||
id="textFieldWidthCh" | ||
inputWidth={4} | ||
label="Input width wide 4 characters" | ||
name="textFieldWidthCh" | ||
placeholder="Placeholder" | ||
type="text" | ||
/> | ||
``` | ||
|
||
This option is generally recommended for inputs with a limited value length | ||
(e.g. numeric representation of day, month, year). Supported values are `2`, `3` | ||
and `4` (characters). | ||
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 you please be more specific? I do not understand why only these values are supported. In the case of day, month, and year it is applicable but in all other cases, it could be any number. So the modification of the default value makes no sense to me. Could you, please, provide some source to enlighte me? :-) 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. The reason is it must be hard-coded in the CSS. I agree it can be noted here. |
||
|
||
### `--width` CSS Custom Property | ||
|
||
If you need any other value or prefer using `em` unit | ||
instead of default `ch`, define a `--width` CSS custom property on the `<input>` | ||
element via `inputProps` attribute: | ||
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. Not applicable to React. Edit. 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. In Twig and React, CSS custom properties are always hidden in the implementation, so this really shouldn't be here. |
||
|
||
```jsx | ||
<TextField | ||
id="textFieldWidthCh" | ||
inputProps="{{ { style: '--width: 10ch' } }}" | ||
label="Input width wide 10 characters" | ||
name="textFieldWidthCh" | ||
placeholder="Placeholder" | ||
type="text" | ||
/> | ||
``` | ||
|
||
### Grid | ||
|
||
For other use cases (wider input or input with unknown value length), we | ||
recommend placing them inside the Grid component and set `isFluid` to `true` to fill the available space. | ||
|
||
## API | ||
|
||
| Name | Type | Default | Required | Description | | ||
|
@@ -50,8 +96,9 @@ TextField with password toggle (button to reveal the password): | |
| `hasPasswordToggle` | `bool` | — | ✔ | If true, the `type` is set to `password` and a password toggle is shown | | ||
| `helperText` | `string` | — | ✕ | Custom helper text | | ||
| `id` | `string` | — | ✕ | Input and label identification | | ||
| `inputWidth` | `number` | — | ✕ | Input width | | ||
| `inputWidth` | `[2, 3, 4]` | — | ✕ | Input width in the characters | | ||
| `isDisabled` | `bool` | — | ✕ | Whether is field disabled | | ||
| `isFluid` | `bool` | — | ✕ | If true, the element spans to the full width of its parent | | ||
| `isLabelHidden` | `bool` | — | ✕ | Whether is label hidden | | ||
| `isRequired` | `bool` | — | ✕ | Whether is field required | | ||
| `label` | `string` | — | ✕ | Label text | | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -56,6 +56,52 @@ Without lexer: | |||||||
}} %} | ||||||||
``` | ||||||||
|
||||||||
## Input Width | ||||||||
|
||||||||
There are several ways to adjust the input width: | ||||||||
|
||||||||
### `inputWidth` Attribute | ||||||||
|
||||||||
The `inputWidth` attribute is supported on inputs of the following types: `email`, | ||||||||
`password`, `tel`, `text`, `url`. | ||||||||
|
||||||||
```twig | ||||||||
<TextField | ||||||||
id="textFieldWidthCh" | ||||||||
inputWidth="4" | ||||||||
label="Input width wide 4 characters" | ||||||||
name="textFieldWidthCh" | ||||||||
placeholder="Placeholder" | ||||||||
type="text" | ||||||||
/> | ||||||||
``` | ||||||||
|
||||||||
This option is generally recommended for inputs with a limited value length | ||||||||
(e.g. numeric representation of day, month, year). Supported values are `2`, `3` | ||||||||
and `4` (characters). | ||||||||
|
||||||||
### `--width` CSS Custom Property | ||||||||
|
||||||||
If you need any other value or prefer using `em` unit | ||||||||
instead of default `ch`, define a `--width` CSS custom property on the `<input>` | ||||||||
element via `inputProps` attribute: | ||||||||
|
||||||||
```twig | ||||||||
<TextField | ||||||||
id="textFieldWidthCh" | ||||||||
inputProps="{{ { style: '--width: 10ch' } }}" | ||||||||
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.
Suggested change
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 have to set invalid value for 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. I don't think we should support this approach, see my comment in the React README. |
||||||||
label="Input width wide 10 characters" | ||||||||
name="textFieldWidthCh" | ||||||||
placeholder="Placeholder" | ||||||||
type="text" | ||||||||
/> | ||||||||
``` | ||||||||
|
||||||||
### Grid | ||||||||
|
||||||||
For other use cases (wider input or input with unknown value length), we | ||||||||
recommend placing them inside the Grid component and set `isFluid` to `true` to fill the available space. | ||||||||
|
||||||||
## API | ||||||||
|
||||||||
| Name | Type | Default | Required | Description | | ||||||||
|
@@ -65,7 +111,7 @@ Without lexer: | |||||||
| `helperText` | `string` | `null` | ✕ | Custom helper text | | ||||||||
| `id` | `string` | — | ✔ | Input and label identification | | ||||||||
| `inputProps` | `string[]` | `[]` | ✕ | Pass additional attributes to the input element | | ||||||||
| `inputWidth` | `number` | `null` | ✕ | Input width | | ||||||||
| `inputWidth` | `[2, 3, 4]` | `null` | ✕ | Input width in the characters | | ||||||||
| `isDisabled` | `bool` | `false` | ✕ | If true, input is disabled | | ||||||||
| `isFluid` | `bool` | `false` | ✕ | If true, the element spans to the full width of its parent | | ||||||||
| `isLabelHidden` | `bool` | `false` | ✕ | If true, label is hidden | | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -86,23 +86,29 @@ The `size` attribute is supported on inputs of the following types: `email`, | |||||||
|
||||||||
This option is generally recommended for inputs with a limited value length | ||||||||
(e.g. numeric representation of day, month, year). Supported values are `2`, `3` | ||||||||
and `4` (characters). If you need any other value or prefer using `em` unit | ||||||||
instead of default `ch`, define a `--width` CSS custom property on the `<input>` | ||||||||
element: | ||||||||
and `4` (characters). | ||||||||
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. As in React, we should explain why these values. |
||||||||
|
||||||||
```html | ||||||||
<div class="TextField"> | ||||||||
<label for="textFieldSize" class="TextField__label">4000 (in Roman numerals)</label> | ||||||||
<label for="textFieldSize" class="TextField__label">Input width wide 4 characters</label> | ||||||||
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.
Suggested change
|
||||||||
<input type="text" size="4" id="textFieldSize" class="TextField__input" name="size" placeholder="Placeholder" /> | ||||||||
</div> | ||||||||
``` | ||||||||
|
||||||||
### `--width` CSS Custom Property | ||||||||
|
||||||||
If you need any other value or prefer using `em` unit | ||||||||
instead of default `ch`, define a `--width` CSS custom property on the `<input>` | ||||||||
element: | ||||||||
|
||||||||
```html | ||||||||
<div class="TextField"> | ||||||||
<label for="textFieldSizeEm" class="TextField__label">4000 (in Roman numerals)</label> | ||||||||
<label for="textFieldWidthEm" class="TextField__label">Input width wide 4em</label> | ||||||||
<input | ||||||||
type="text" | ||||||||
size="4" | ||||||||
id="textFieldSizeEm" | ||||||||
id="textFieldWidthEm" | ||||||||
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.
Suggested change
|
||||||||
class="TextField__input" | ||||||||
name="sizeEm" | ||||||||
name="textFieldWidthEm" | ||||||||
placeholder="Placeholder" | ||||||||
style="--width: 4em;" | ||||||||
/> | ||||||||
|
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.
IDs should be turned into kebab-case.