[WIP] Cross-platform components for web/Figma/Sketch/React Native#745
[WIP] Cross-platform components for web/Figma/Sketch/React Native#745macintoshhelper wants to merge 8 commits intoprimer:masterfrom
Conversation
|
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/primer/primer-components/p687ontbv |
|
Hey @macintoshhelper! This is a really neat idea & thanks so much for doing this work and opening a PR! Unfortunately, we already have a Figma component library that we're using across product design as a single source of truth and don't have plans for using our React code as that source of truth in the near future. Because this approach would create a bit more complexity in our styled components code and the Primer core team would need to maintain that across all our components, it don't think it makes sense to go forward with this approach for now. Additionally, we aren't yet using our React components cross platform, but if/when we do, I'd love to circle back on this 🙌 |
Hi @emplums , thanks! Yes, I appreciate that this is a large task and would require a big effort to use the new component library internally, especially in terms of migration of existing design files/assets, and is unlikely to fit the current design processes/workflow. My main goal was to float the idea and explore the feasibility of migrating an existing codebase to render straight to design, and I'm surprised how close the Figma output is to the web design for atomic components like buttons, relative to the code changes needed 🙂.
Yes, I agree that there'd be extra maintenance for the styled components code, especially as native platforms don't have CSS inheritance, pseudo selectors, etc, so this functionality has to be polyfilled in a manner which would require onboarding for all devs. I think the complexity can be balanced out by the benefits of having a very component-driven, functional/test-driven and side-effect free process, but this would need to be part of a long-term effort and shift in technical direction, and makes more sense to invest in if using I'll carry on the work at https://github.com/elemental-design/ as a community effort, and will move the fork over to https://github.com/elemental-design/primer-components , and will work on abstracting as much of the work as I can into libraries (e.g. Do you have any thoughts on having the fork showcased for community/third party use of this library? I've seen that there seems to be interest in having publicly available Primer Figma assets, so maybe having an unofficial community-maintained Figma style-guide and component library using this fork would be interesting? |
Don't merge yet
This exists mostly as a proof-of-concept for now, to go together with the proposal issue #744 🙂. I'd love feedback on it to see if this something worth working on further and that is likely to be merged.
Abstract
Implements cross-platform resolving for
styled-componentsthat allows this project to be imported intoreact-dom,react-native,react-sketchappandreact-figmaprojects.This is a bit of a refactor that adds custom platform handling logic across the codebase, using
react-primitives. Webpack aliasing in the Figma/(other native platforms) entrypoint is used where possible to keep the project friendly for web developers, and not usereact-native-webfor web to maintainstyled-componentsSSR support and keep bundle sizes low.Webpack resolving examples:
import styled from 'styled-components'->import styled from 'styled-components/primitives'on native platforms onlystyled.button->styled.Viewon native platforms onlyQuote from https://github.blog/2018-04-12-driving-changes-from-designs/#excited-about-the-future
Closes #744
The goal
The main idea of this is to allow the same Primer components codebase to be able to automatically generate Figma and Sketch component libraries (and styleguides), with
react-figmaandreact-sketchapprespectively. As an added bonus, the components can be used in React Native (or ReactXP potentially) codebases.CI could also be used to automatically generate Figma/Sketch style-guides using a library like
@elemental-design/style-guide, taking thestyled-systemtheme.jsand components as an input and outputting cross-platform Figma/Sketch/storybook/Gatsby style-guide documentation. This could be integrated inside ofDoctocat.So, as an example, a new
primer/style-guiderepo could be created, with cross-platform compatible markdown docs migrated over to there, and it'll accept athemeobject and components list as inputs, and can be used as a dependency inDoctocator theFigmaentrypoint.Platform-specific page entrypoint:
primer/style-guide–docs/buttons.mdfile, that can be imported into Doctocat, Figma style-guide jsx, etcScreenshots
TODO
Merge checklist
index.d.ts) if necessary(will do the above if/once it's past proposal stage)
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.