-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Components: Integrate TextInput component [WIP] #32381
Conversation
@@ -40,6 +40,7 @@ export default { | |||
controlPaddingXLarge: `calc(${ CONTROL_PADDING_X } * 1.3334)`, | |||
controlPaddingXSmall: `calc(${ CONTROL_PADDING_X } / 1.3334)`, | |||
controlBackgroundColor: COLORS.white, | |||
controlBackgroundColorHover: 'rgba(0, 0, 0, 0.5)', |
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.
I took this straight from G2's controlBackgroundColorHover.
What's the best way to migrate these styles and know which is the default?
Or are we going to clean up/make things consistent across the board later?
@@ -50,6 +51,8 @@ export default { | |||
controlHeightLarge: `calc( ${ CONTROL_HEIGHT } * 1.2 )`, | |||
controlHeightSmall: `calc( ${ CONTROL_HEIGHT } * 0.8 )`, | |||
controlHeightXSmall: `calc( ${ CONTROL_HEIGHT } * 0.6 )`, | |||
controlInnerControlTextColor: COLORS.darkGray, | |||
controlTextColor: COLORS.darkGray, |
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.
Same as above. These are fairy arbitrary and are probably wrong, or belong in COLORS.
I'm not aware of any system to follow 🤷
462bd8c
to
6fac8fd
Compare
Hey @ramonjd, thank you for working on this PR! I took a look at this PR, and it looks like there are still quite a few build errors that prevent you from running the Storybook story correctly. I tinkered around on my local machine and came up with these fixes:
Since I don't seem to have write rights on your PR branch, I've prepared a diff including the code changes from points 2 to 5 (expand to reveal)diff --git a/package-lock.json b/package-lock.json
index 5a52107892..e450e3268b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13224,7 +13224,9 @@
"memize": "^1.1.0",
"moment": "^2.22.1",
"re-resizable": "^6.4.0",
+ "react-autosize-textarea": "^7.1.0",
"react-dates": "^17.1.1",
+ "react-number-format": "^4.6.0",
"react-resize-aware": "^3.1.0",
"react-spring": "^8.0.20",
"react-use-gesture": "^9.0.0",
@@ -51265,6 +51267,14 @@
"prop-types": "^15.5.10"
}
},
+ "react-number-format": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/react-number-format/-/react-number-format-4.6.0.tgz",
+ "integrity": "sha512-0Td7QM3FGFVOw+DzYooLae50d6r67hZcinbDy5TQRQJB9+/p1caX+NQQ6PW408H+nZTKgykknQHv6L6PPoRO2w==",
+ "requires": {
+ "prop-types": "^15.7.2"
+ }
+ },
"react-outside-click-handler": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/react-outside-click-handler/-/react-outside-click-handler-1.3.0.tgz",
diff --git a/packages/components/src/text-input/styles.js b/packages/components/src/text-input/styles.js
index 1e690a4b54..b302a7cc1a 100644
--- a/packages/components/src/text-input/styles.js
+++ b/packages/components/src/text-input/styles.js
@@ -26,7 +26,7 @@ export const inputMultiline = css`
`;
export const inputFontSize = css`
- font-size: CONFIG.fontSizeInputMobile;
+ font-size: ${ CONFIG.fontSizeInputMobile };
@media ( min-width: 36em ) {
font-size: ${ CONFIG.fontSize };
}
@@ -36,10 +36,10 @@ export const Input = css`
appearance: none;
background: transparent;
border: none;
- border-radius: CONFIG.controlBorderRadius;
+ border-radius: ${ CONFIG.controlBorderRadius };
box-shadow: none;
box-sizing: border-box;
- color: CONFIG.controlTextColor;
+ color: ${ CONFIG.controlTextColor };
display: block;
flex: 1;
line-height: 18px;
diff --git a/packages/components/src/text-input/text-input-arrows.js b/packages/components/src/text-input/text-input-arrows.js
index 5ba2dd8dc0..90b4b8a0c7 100644
--- a/packages/components/src/text-input/text-input-arrows.js
+++ b/packages/components/src/text-input/text-input-arrows.js
@@ -18,7 +18,7 @@ import {
/**
* Internal dependencies
*/
-import { Icon } from '../icon';
+import Icon from '../icon';
import { View } from '../view';
import { VStack } from '../v-stack';
import * as styles from './styles';
diff --git a/packages/components/tsconfig.json b/packages/components/tsconfig.json
index 188a594d27..65df915199 100644
--- a/packages/components/tsconfig.json
+++ b/packages/components/tsconfig.json
@@ -33,6 +33,7 @@
"src/shortcut/**/*",
"src/spinner/**/*",
"src/spacer/**/*",
+ "src/text-input/**/*",
"src/tip/**/*",
"src/truncate/**/*",
"src/ui/**/*",
I recommend running With these fixes in place, the Unfortunately, I didn't have enough time to go to the bottom of this, but I noticed that the Another good resource is this short guide by @sarayourfriend on migrating g2 components to |
@ciampo Thanks so much for looking at this, and sorry I left so many silly errors in there. I had fixed some of the more basic ones like imports and interpolation locally but, as always, forgot to push 🤦 I appreciate your help, and will follow your advice above to keep digging away 🙏 |
5846389
to
6df54c9
Compare
I might chip away slowly at this. There are a bunch of Typescript errors that run deep and/or across files, and whose priorities I'm not quite sure. Whenever @sarayourfriend is next available to lend some 👀 I'd be sure grateful for your advice too! Thanks! |
c5fc215
to
0e56556
Compare
Don't mention it! And feel free to ping me again :) |
e550180
to
183a4b9
Compare
packages/components/src/text-input/hooks/use-text-input-state-utils.js
Outdated
Show resolved
Hide resolved
packages/components/src/text-input/hooks/use-text-input-state.js
Outdated
Show resolved
Hide resolved
20e1c14
to
ebd65b5
Compare
Thanks so much for the detailed review @sarayourfriend ❤️ . Really helpful. Yes, this is a big one! :) My eyes were too big for my 🧠, but I'm learning a whole bunch along the way. I'll slowly chip away where I can. There are some type errors I've ignored, mostly related to Also I can look into moving those utils into packages if you think it's okay. Would it make more sense to do it in separate PRs? |
I think based on @gziolo's answer we can ignore those questions of mine 🙂 Feel free to ping with any questions regarding the types. They can be pretty non-obvious to work with... 😞 |
Reformatting Guessing styles and config
…ts. Some utils could be exported from /utils/index.js Adding stories Exporting TextInput in components/index.js Formatting steppers Trying to get the story to appear in storybook Added 2 x dependencies: react-autosize-textarea and react-number-format. Formatting tests Updated snapshot Adding type annotations Updating type declarations across TextInput Updating snapshots Editing README Fixing types paths
Adding extra tests.
ebd65b5
to
27f6bfc
Compare
🚧 WIP
Description
This PR integrates the g2 TextInput component.
Integration tracking issue: #30503
Related: #28399
How has this been tested?
This is a new component.
We'll check that:
npm run storybook:dev
so I've removed the import fromtsconfig.json
for now.Screenshots
To come...
Types of changes
A new feature
Checklist:
*.native.js
files for terms that need renaming or removal).