-
Notifications
You must be signed in to change notification settings - Fork 17
Implemented EdsIcon
component
#227
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
Implemented EdsIcon
component
#227
Conversation
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.
just a few questions from somebody who is new to typescript...
icon: PropTypes.string.isRequired, | ||
size: PropTypes.oneOf([16, 24, 32, 40, 48]), | ||
color: PropTypes.string, | ||
}; |
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.
so how come you have to define the propTypes twice? and why does one need this very thin jsx
wrapper around the tsx
file? I'm sorry, I'm rather new to typescript...
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.
This is in order to make dash-generate-components
recognize the component when creating the Python wrapper around it. With the newer versions of Dash it should be able to recognize TypeScript, but there are still some issues with the newest Dash version so we cannot use it yet.
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.
As you can see, we followed this pattern for all components in wcc
. By the time the new solution is in place, we are going to adjust the whole package (including operations in the package.json
). If you wonder why we're defining TypeScript and PropTypes, they are not doing exactly the same. TypeScript is checked at build time while PropTypes are checked at runtime. Since we don't know the exact context in which the components are going to be used (might be in e.g. an API with types coming in at runtime), we are equipping our components with both, build and runtime type checking.
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.
ah, cool! thanks for the explanation!
@@ -0,0 +1,13 @@ | |||
import React from "react"; |
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.
is this import statement necessary? I don't see where you use React
below.
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.
This seems to be a leftover from the copy-paste operation and can be removed ;)
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.
ah, yummy copypasta, my favorite ^^
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 stay corrected: before, each JSX
component had to be in the React scope - hence, React must be imported, no matter if it is used or not. This is because the JSX
file is converted to a JavaScript file in which the React.createElement
is used (see here: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html). The new JSX transform does not require this anymore, but we don't have the setup adjusted yet. Hence, we have to keep it for now.
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.
aha, right! that makes sense, I read about the JSX
and how it's transformed. cool! thanks for the further explanation ^^
986302d
to
15d7db8
Compare
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.
Apart from the (for me dead?) link and my question, this looks good.
Sadly I wasn't able to inject the to be merged version of webviz-core-components into our app (using a simple pip install from github command, the setup script couldn't find package.json) to test the component live, in action, so I'm gonna rely on you having tried out what it actually looks like : )
Thank you very much!
`An icon with name "${props.icon}" does not exist.` + | ||
` Please check the icon name for typos. ` + | ||
`An overview of all available icons can be found at ` + | ||
`https://eds.equinor.com/assets/system-icons/library/.` |
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.
that link is a 404, at least for me from an unmanaged laptop connected to Statoil-Approved
i managed to access the storybook for icons though, under
https://eds-storybook-react.azurewebsites.net/?path=/story/icons--preview
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.
Yep, seems like EDS changed their website. I will adjust the link. Thanks for the catch!
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.
no worries : )
color?: string; | ||
}; | ||
|
||
export const EdsIcon: React.FC<IconProps> = (props) => { |
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'm a complete noob when it comes to typescript, and haven't worked much with React either, so this review is probably at most a chance for me to learn something, but anyways - I would have expected the props
lambda function argument to be typed, but I suspect that the type is indirectly encoded in React.FC<IconProps>
? : )
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.
Yes, that is correct.
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.
cool, thanks!
@valentin-krasontovitsch you can test a
|
ah cool thank you! gonna try it out : ) |
and of course:
: D |
okay i think i'm doing something wrong here.
any pointers? |
@valentin-krasontovitsch ah sorry, I forgot that you did not have any setup at all. Before running for the first time, you have to install both all required npm packages and Python packages. In addition, you need a version of Node.js (do you have one installed? - if not I'd recommend to use NVM (https://github.com/nvm-sh/nvm) - a Node Version Manager - and install the latest LTS version of Node.js - 16.16.0 at the moment: https://nodejs.org/en/). When Node.js is installed, you can run
Then the initial setup is done and you can use the commands I mentioned further up. |
tried it, but still the second command complains with the same error as above 🤔 |
just for future prosperity - in a video meet, we found out that we should copy tested functionality manually and visually, looking great, nonsensical icon text yields desired warning icon with help text. coolio! |
oh also needed to use |
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.
Tested and verified. Look good! 👍
This PR introduces a new React component named
EdsIcon
. The component accepts up to three properties:icon
,color
andsize
. With this component, icons from the Equinor Design System (EDS) can be used directly in Python.This PR closes #224.