Skip to content
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 TextFields README.md about missing section inputWidth #1269

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dlouhak
Copy link
Contributor

@dlouhak dlouhak commented Feb 7, 2024

No description provided.

@dlouhak dlouhak added the documentation Improvements or additions to documentation label Feb 7, 2024

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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not applicable to React. Edit.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@coveralls
Copy link

coveralls commented Feb 7, 2024

Coverage Status

coverage: 80.979% (-15.4%) from 96.371%
when pulling d788ea2 on docs/extend-textfield-readme-about-input-width-section
into 7cfdc20 on main.

Copy link

netlify bot commented Feb 7, 2024

Deploy Preview for spirit-design-system-storybook ready!

Name Link
🔨 Latest commit d788ea2
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-storybook/deploys/65c3a01dcb8fee0008780071
😎 Deploy Preview https://deploy-preview-1269--spirit-design-system-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 7, 2024

Deploy Preview for spirit-design-system-react ready!

Name Link
🔨 Latest commit d788ea2
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-react/deploys/65c3a01d38d2810008084da8
😎 Deploy Preview https://deploy-preview-1269--spirit-design-system-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Feb 7, 2024

Deploy Preview for spirit-design-system-validations canceled.

Name Link
🔨 Latest commit d788ea2
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-validations/deploys/65c3a01d34f9c500088001df

Copy link

netlify bot commented Feb 7, 2024

Deploy Preview for spirit-design-system-demo ready!

Name Link
🔨 Latest commit d788ea2
🔍 Latest deploy log https://app.netlify.com/sites/spirit-design-system-demo/deploys/65c3a01d0499590008043d1a
😎 Deploy Preview https://deploy-preview-1269--spirit-design-system-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

<input
type="text"
size="4"
id="textFieldSizeEm"
id="textFieldWidthEm"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id="textFieldWidthEm"
id="textFieldWidthEm"
size="4"

```twig
<TextField
id="textFieldWidthCh"
inputProps="{{ { style: '--width: 10ch' } }}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inputProps="{{ { style: '--width: 10ch' } }}"
inputProps="{{ { style: '--width: 10ch' } }}"
inputWidth="10"

Copy link
Contributor Author

@dlouhak dlouhak Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to set invalid value for inputWidth otherwise style via CSS property isn't applied. Not intuitive.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.


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).
Copy link
Collaborator

Choose a reason for hiding this comment

The 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? :-)

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@literat
Copy link
Collaborator

literat commented Feb 12, 2024

👏 Thanks for this contribution and a big update of our docs. Otherwise, there are some changes I do not really understand. If you can provide more detail to me, it would be great :-)

@dlouhak
Copy link
Contributor Author

dlouhak commented Jun 27, 2024

We've discussed with @adamkudrna and we suggest slightly change the API.

  • do not set range between 2-4 characters for size, but enable to pass any numeric value (Web BC)
  • size property won't be used at all (Web BC), instead of it we will use inputWidth
  • extend React APIs about inputWidth (React feature)
  • inputWidth pass as custom property in Twig (Twig fix, see this comment)

@adamkudrna
Copy link
Contributor

adamkudrna commented Jun 27, 2024

We've discussed with @adamkudrna and we suggest slightly change the API.

  • do not set range between 2-4 characters for size, but enable to pass any numeric value (Web BC)
  • size property won't be used at all (Web BC), instead of it we will use inputWidth
  • extend React APIs about inputWidth (React feature)
  • inputWidth pass as custom property in Twig (Twig fix, see this comment)

Resulting CSS could look like this:

.TextField__input--customWidth {
    box-sizing: content-box;
    width: calc(var(--width, 3) * 1ch + var(--arrows-width, 0px));
}

Copy link
Contributor

@adamkudrna adamkudrna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing! 🙏🏻


```jsx
<TextField
id="textFieldWidthCh"
Copy link
Contributor

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.


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:
Copy link
Contributor

Choose a reason for hiding this comment

The 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.


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).
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

```twig
<TextField
id="textFieldWidthCh"
inputProps="{{ { style: '--width: 10ch' } }}"
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

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).
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<label for="textFieldSize" class="TextField__label">Input width wide 4 characters</label>
<label for="textFieldSize" class="TextField__label">Input width of 4 characters</label>

@adamkudrna adamkudrna assigned adamkudrna and unassigned dlouhak Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants