Show HN: Antd – A set of high-quality React components
ant.design
ant.design
The first (and presumably namesake) company is Ant Financial https://www.antgroup.com, which is described as:
> Ant Financial Services Group ("Ant Financial"), was officially founded in October 2014 and originated from Alipay which is the world's leading third-party payment platform founded in 2004.
So basically if Bootstrap came out of Twitter, this came out of Alibaba and Co. Big name behind it.
I'm looking at the demos now, but my main concern is how these behave on mobile apps. Performance, ease of development, etc. I have little concern for how they behave on my mac, fwiw. (performance on my mac may be related to mobile performance, but due to the very different architecture behind ReactNative style mobile apps, i'm skeptical to compare desktop performance)
Fascinating. This is probably the first time I've seen a huge open source project where a majority of the contributions are in a language that's not English. I've seen plenty of projects from non-native English speakers, but everything was still done in English.
I'm sure there are tons of other big projects in Chinese and other languages, but programming has always been very English-centric. I had heard of programming languages that use other languages or alphabets, but they were all very esoteric.
I've also seen people using foreign languages for class and method names, while all of the framework APIs and programming language keywords were English.
So I guess it's only fair that I should learn some Chinese. Weex does look very good.
I just looked at this issue, for example: https://github.com/alibaba/weex/issues/1746
It's funny how all of the Java variables and keywords, HTML tags, and the CSS is all English (or at least, programming languages based on English words), while the issue details are written in Chinese. It's a really interesting mix.
I wonder if there are transpilers that let people write code in their native language, and then convert everything into English source code. It should be very easy, it's just a search/replace for keywords like "public", "protected", "length", "super", "return", etc. etc.
At the end of the day, english has "won" as the language of keywords in programming. And while i'm glad that most newer languages have the ability to code everything but keywords in your native language (i've worked with JS that has variables and function names in other scripts), translating the keywords seems like a pointless process that would do nothing but cause incompatibility.
[0] https://en.wikipedia.org/wiki/Non-English-based_programming_...
Another issue is your DropDown breaks the power user convention of being able to type the first letter (or more) of an item and the dropdown selecting it.
More than 50 system use this framework in Ant Financial.
That said, the first time I loaded the page sure took a long time. Kind of sad to need Webpack to create chunks just to recreate the old effect of not loading all the content for your website all at once.
Some of the controls were hard to navigate on an iPad Pro. Time in particular was hard to use, not enough space. This is a fault of the resolution of the pro, but if the targets aren't big enough, I'm scrolling the page instead of the hours.
Is it possible to convert the remaining site pages [0] into english.
Also, the mobile friendly components [1] also look great.
[1]https://material.google.com [2]https://www.npmjs.com/package/antd
[0] https://github.com/palantir/blueprint/issues/202#issuecommen...
It appears the team chose to make an oddly generically named babel plugin: `babel-plugin-import` which seems to do some manipulation of CSS/SASS/etc styles (which seems out of scope for babel). I assume the generic name was chosen hoping other libraries would embrace a similar pattern, however, I'm not seeing any spec defining how another library should implement this.
Always up to use a new tool!
The project appears to have far fewer features than the react project at this time
While I did like some components from Antd and intend to look into the source, from a basic overview, a lot of the documentation seems to be in Chinese.
Is this by Stripe? The components look just like their dashboard.
Is someone already working on a bootstrap-themed version of this?
Also, this is native HTML and CSS of course, with proper definition, types and handlers laying out what the component can do:
https://github.com/ant-design/ant-design/blob/master/compone...
https://github.com/ant-design/ant-design/blob/master/compone...
Resulting in: https://ant.design/components/button/
<button>Hello world</button>To "just" use self contained, configurable, property-defined components that can be shared, re-used, filled with state - that isn't trivial. Which is why they're React components. The components themselves are very lean, there's a bit of code, some markup, a piece of CSS and that's that. The code i have linked compiles down to a couple of bytes.
How does it compare ?
But you can import component individually by using this babel plugin https://github.com/ant-design/babel-plugin-import, see https://ant.design/docs/react/getting-started#Import-on-Dema...
People on this thread are saying it's the network speed thing, coming from china and all, but isn't this supposed to have downloaded all the js modules initially?
I just keep thinking "it would have been much faster and I wouldn't have to wait for these progress bars to finish if it were just a static page".
Why does a documentation need a progress bar anyway?
The data is static and it is probably a SPA, but it's not all loaded on the initial load.
There is a standard for CSS variables and a very functional subset of their functionality can be compiled for older browsers at build time: http://cssnext.io, yet as far as I can tell, all of these component frameworks impose some other nonstandard compiles-to-CSS language or one of many possible APIs for writing inline styles.
Inline styles seem to be a trend at the moment but I can only assume the people driving this movement haven't had the experience of working with 3rd party components (which you may or may not have the source for) and needing to alter something the designers didn't expose and simply having no simple options because the damn inline style can't be overridden even by !important. Now you've got to fork whole the f'ing component, possibly multiple, each of which potentially coming with yet another different compiles-to-CSS toolchain all because you wanted to add a single line of CSS.
Admittedly, antd doesn't use inline styles si the above doesn't apply here, but having to maintain a custom builder for antd in order to change some fonts and a few colors was a frustrating experience. Not sure what a good solution is until CSS variables get more browser adoption, but it'd be great if we could collectively start standardizing on standards.
I don't think your complaint is relevant here, especially since you provide no solution.
It bothers me that this reply is at the top of the comments.
I use libsass and postcss combined and pretty happy about it.
I'm one of the maintainers of ElementalUI, and Glen Maddern, the styled-components co-creator, one of the creators of CSS Modules. One of the biggest downsides of CSS Modules (and, by extension, every other styles in JavaScript library right now) is that theming is simply impossible. Building third-party component libraries is hard enough, but providing an easy-to-theme API wasn't a solved problem in the React world. Nobody has done it properly, and there is no agreed-upon way of doing this!
styled-components has built-in theming support[1] to solve this exact problem. (note: this is CSS-in-JS, not inline styles[2], so overriding is easy as pie too[3]) We're rebuilding ElementalUI with it right now and the next versions of react-toolbox and Belle will be built with it as well.
We also have ReactNative support, which nobody else has done before. Just because you're writing a universal React app with a third-party component library shouldn't mean switching between three or four different APIs to style your app. With styled-components, you can just use styled-components no matter what you're styling!
(If you're reading this, I'd love to have a chat with the Antd people about maybe moving to styled-components! You can reach me on Twitter at @mxstbr, just ping me there!)
[0]: https://styled-components.com
[1]: https://github.com/styled-components/styled-components#theming
[2]: mxstbr.blog/2016/11/inline-styles-vs-css-in-js
[3]: https://github.com/styled-components/styled-components#overriding-component-styles[1]: https://github.com/styled-components/styled-components/issue...
We also almost have a proper server-side rendering API[0], in case you haven't seen that PR before. Should be released very soon!
[0]: https://github.com/styled-components/styled-components/pull/...
I've been using Antd components for the last year in some my project. All components are also available here[0] as single modules for better reusability and customization.
Currently, I have solved all my theming goals with Plain CSS. For each component, that I'd like to customize I created a wrapper
import Slider from 'rc-slider';
function StyledSlider(props) {
return <Slider className="my-slider" {...props} />
}
Then in CSS .my-slider .rc-slider-track {
background: #FFDF66;
}
(This is a very simplified example, just shows the way).I have read about styled-components, but I don't understand how it would help me with theming. I don't think that rewriting every component from LESS to styled-components to make possible to use ThemeProvider will be an option because it doesn't give you any benefits comparing with customization guide[1], that also gives you good enough way to override defaults.
[0]: https://github.com/react-component/
[1]: https://ant.design/docs/react/customize-themeThe TL;DR is that this customization guide will suddenly become really easy. Antd can specify a default theme and users can override the parts of the default theme they want!
All the user has to do is pass a single prop to the ThemeProvier and override what they want:
import { ThemeProvider } from 'antd';
<ThemeProvider theme={{ primaryColor: '#1DA57A' }}>
<App />
</ThemeProvider>
On top of that different parts of your app can have different themes. Making your sidebar dark but your main component light is not an issue – just wrap them in two ThemeProviders with different themes: <ThemeProvider theme={darkTheme}>
<Sidebar />
</ThemeProvider>
<ThemeProvider theme={lightTheme}>
<Main />
</ThemeProvider>
It's also all dynamic, meaning you can let the users of your app provide custom themes for your app and it'll automatically apply.Compare that with the current customization guide, not only do users have to use webpack, they also have to use specific plugins just to make customization of third-party components work! It's also all global, which means styling the sidebar dark and the main area light is impossible since it's all just Less variables applied at build time. This also makes it very hard to have user supplied themes.
Does that make it clear enough how using styled-components would help with theming? :-)
Currently, I (as well as most users, I suppose) just need to apply some global color overrides to match with company's brand guidelines that I can solve it with old good plain CSS.
Also, for big projects, like Antd, transition to some other CSS-tooling almost impossible, because CSS/LESS code is spread across several repositories and will take a lot of efforts and time.
And finally, the current implementation is better because it doesn't mention styles in Javascript at all, so the library users are able to choose any way to style components without extra efforts from the side of library authors.
Imagine Button being a styled component, all of the usual methods work perfectly fine:
import Button from 'antd';
<Button className="my-global-classname" />
<Button style={{ color: 'red' }} />
You say "just" apply some global color overrides, but to "just" apply some global color overrides you need to use webpack (using another bundler? Sorry, antd is not for you) and use atool-build or have to configure webpack to work the way they need it to.Or you create a custom less file, but that means you'll load all the styling for all components even though you really only wanted to use e.g. the Button.
That's not really "just" overriding a global color, is it? ;-)
I'm not saying this is a trivial change at all by the way, I understand the cost of it since I'm doing it for ElementalUI. I don't know if the antd maitainers will consider it worth it, that's another discussion.
If you use a CSS react-lib like React-CSJS, styling this is easy as pie.
At least on paper, it solved the issues you raise. Time will tell I suppose.
I'm currently working on themes for a similar framework. It's still in early stage but you can see it here: http://cx.codaxy.com/v/master/themes/
You can separate component Style into - BASE + States classes.
classnames[0] can used to use multiple classes, the classes can be activated using component state. This provides a viable solution for Structure & Style.
What you want from theming is a global skin. You want users of your component library to be able to say "I want all of my buttons to be red" without having to wrap the component or pass a prop to every component. (simplified example)
Doing so just with class names is very very hard. It's what we've done for ElementalUI (together with Less), but it just doesn't work – it's a pita for users!
I've had some success with simple find & replace preprocessor but this gets complicated if the CSS uses colour manipulation functions e.g. color: color(var(--color-base) tint(50%)), then you're basically going to be re-implementing their whole stylesheet again.
Also, good luck making sure everything still works if and when the components are updated.
Ideally, you alter theme variables in one place, rather than finding and overriding them everywhere they're applied.
For mobile platforms specifically. Now on the surface you can say that UI libraries these days, more or less, will work similarly if not exactly the same across platforms. I would say for most "types" of components this will be true. But form input field behavior is different enough between mobile platforms that I'm questioning why we aren't moving quickly away from native HTML form input fields.
I totally get the argument for accessibility (probably a lot of accessibility platforms depend on these fields), but even accessibility standards such as ARIA, because of some of these inconsistencies, should be pushing toward this goal (decoupling the form input UI components from native HTML form input fields) I think.
Does anyone else here have a strong opinion one way or another as far as their experience building PWA's on mobile where they've encountered the differences between platforms (I'm specifically familiar with Android vs. iOS)? Do you find the differences to be easy to work around? I'm especially interested in feedback from folks who have required some relatively detailed behaviors, such as consistency in how input fields behave when "tabbing" to the next / previous field, or how the "input type='time'" fields behave differently in terms of when DOM events fire while setting time. Or how native keyboard behaviors / layouts are sufficiently different that you'd prefer to have a way to make the experience within your app more consistent?