material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[Joy][docs] Add documentation for `Input` component

Open hbjORbj opened this issue 3 years ago • 1 comments

As we are progressing towards removing TextField from Joy UI (https://github.com/mui/material-ui/pull/35462) (https://github.com/mui/material-ui/issues/34176), documentation for Input component has become essential.

Preview: https://deploy-preview-35482--material-ui.netlify.app/joy-ui/react-input

hbjORbj avatar Dec 14 '22 13:12 hbjORbj

Messages
:book: Netlify deploy preview: https://deploy-preview-35482--material-ui.netlify.app/

No bundle size changes

Generated by :no_entry_sign: dangerJS against 9230e2e019f6c5c145e4104537f1205527bfe6cc

mui-bot avatar Dec 14 '22 13:12 mui-bot

@siriwatknp I restructured the docs, polished and added a common example "newsletter subscription", inspired by https://dribbble.com/shots/14442751-Newsletter-Subscribe-Animation; Let me know!

hbjORbj avatar Dec 21 '22 18:12 hbjORbj

@siriwatknp I restructured the docs, polished and added a common example "newsletter subscription", inspired by https://dribbble.com/shots/14442751-Newsletter-Subscribe-Animation; Let me know!

Thanks, @hbjORbj. After seeing the subscription demo, I think the input deserves to have a CSS variables playground to help developers create their own version of Input.

Here is the list of variables that should be in the playground.

  • --Input-radius
  • --Input-gap
  • --Input-placeholderOpacity
  • --Input-focusedThickness
  • --Input-minHeight
  • --Input-paddingInline
  • --Input-decorator-childHeight

The input preview should have:

  • placeholder
  • an icon as the start decorator
  • a button (or icon button) as the end decorator

siriwatknp avatar Dec 22 '22 04:12 siriwatknp

Hey, Jun, I added CSS variable playground. Opacity can't be in px, so I made some changes to JoyVariablesDemo.tsx. e.g.,

index 8ef657dc55..861acb8320 100644
--- a/docs/src/modules/components/JoyVariablesDemo.tsx
+++ b/docs/src/modules/components/JoyVariablesDemo.tsx
@@ -15,11 +15,11 @@ import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown';
 
 interface DataItem {
   var: string;
-  defaultValue?: string;
+  defaultValue?: string | number;
   helperText?: string;
 }
Screenshot 2022-12-22 at 09 52 41

I wanted to make the stepper to increment/decrement by 0.1 but I couldn't find where that stepper is coming from. I found that it disappears when I remove type='number' from TextField, but couldn't locate the logic in the behind-the-scenes. Can you help?

hbjORbj avatar Dec 22 '22 14:12 hbjORbj

Hey, Jun, I added CSS variable playground. Opacity can't be in px, so I made some changes to JoyVariablesDemo.tsx. e.g.,

index 8ef657dc55..861acb8320 100644
--- a/docs/src/modules/components/JoyVariablesDemo.tsx
+++ b/docs/src/modules/components/JoyVariablesDemo.tsx
@@ -15,11 +15,11 @@ import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown';
 
 interface DataItem {
   var: string;
-  defaultValue?: string;
+  defaultValue?: string | number;
   helperText?: string;
 }
Screenshot 2022-12-22 at 09 52 41

I wanted to make the stepper to increment/decrement by 0.1 but I couldn't find where that stepper is coming from. I found that it disappears when I remove type='number' from TextField, but couldn't locate the logic in the behind-the-scenes. Can you help?

It is the native HTML input attribute https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step.

siriwatknp avatar Dec 26 '22 05:12 siriwatknp

Made some improvements to JoyVariablesDemo.tsx. DataItem now has an extra prop inputAttributes?: React.InputHTMLAttributes<HTMLInputElement>; e.g.,

        {
          var: '--Input-placeholderOpacity',
          defaultValue: 0.5,
          inputAttributes: {
            min: 0.1,
            max: 1,
            step: 0.1,
          },
        },

Inner HTML input demo is ready as well.

hbjORbj avatar Dec 26 '22 16:12 hbjORbj