Giter Club home page Giter Club logo

styled-components-website's Introduction


Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress πŸ’…

downloads: 600k/month Discord gzip size module formats: umd, cjs, esm Code Coverage

Upgrading from v5? See the migration guide.

Utilizing tagged template literals (a recent addition to JavaScript) and the power of CSS, styled-components allow you to write actual CSS code to style your components. It also removes the mapping between components and styles – using components as a low-level styling construct could not be easier!

const Button = styled.button`
  color: grey;
`;

Alternatively, you may use style objects. This allows for easy porting of CSS from inline styles, while still supporting the more advanced styled-components capabilities like component selectors and media queries.

const Button = styled.button({
  color: 'grey',
});

Equivalent to:

const Button = styled.button`
  color: grey;
`;

styled-components is compatible with both React (for web) and React Native – meaning it's the perfect choice even for truly universal apps! See the documentation about React Native for more information.

Supported by Front End Center. Thank you for making this possible!


See the documentation at styled-components.com/docs for more information about using styled-components!

Quicklinks to some of the most-visited pages:


Example

import React from 'react';

import styled from 'styled-components';

// Create a <Title> react component that renders an <h1> which is
// centered, palevioletred and sized at 1.5em
const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: palevioletred;
`;

// Create a <Wrapper> react component that renders a <section> with
// some padding and a papayawhip background
const Wrapper = styled.section`
  padding: 4em;
  background: papayawhip;
`;

function MyUI() {
  return (
    // Use them like any other React component – except they're styled!
    <Wrapper>
      <Title>Hello World, this is my first styled component!</Title>
    </Wrapper>
  );
}

This is what you'll see in your browser:


Looking for v5?

The main branch is for the most-current version of styled-components, currently v6. For changes targeting v5, please point your PRs at the legacy-v5 branch.


Built with styled-components

A lot of hard work goes into community libraries, projects, and guides. A lot of them make it easier to get started or help you with your next project! There are also a whole lot of interesting apps and sites that people have built using styled-components.

Make sure to head over to awesome-styled-components to see them all! And please contribute and add your own work to the list so others can find it.


Contributing

If you want to contribute to styled-components please see our contributing and community guidelines, they'll help you get set up locally and explain the whole process.

Please also note that all repositories under the styled-components organization follow our Code of Conduct, make sure to review and follow it.


Badge

Let everyone know you're using styled-components β†’ style: styled-components

[![style: styled-components](https://img.shields.io/badge/style-%F0%9F%92%85%20styled--components-orange.svg?colorB=daa357&colorA=db748e)](https://github.com/styled-components/styled-components)

Contributors

This project exists thanks to all the people who contribute. [Contribute].


Backers

Thank you to all our backers! πŸ™ [Become a backer]


Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]


License

Licensed under the MIT License, Copyright Β© 2016-present Glen Maddern and Maximilian Stoiber.

See LICENSE for more information.


Acknowledgements

This project builds on a long line of earlier work by clever folks all around the world. We'd like to thank Charlie Somerville, Nik Graf, Sunil Pai, Michael Chan, Andrey Popp, Jed Watson & Andrey Sitnik who contributed ideas, code or inspiration.

Special thanks to @okonet for the fantastic logo.

styled-components-website's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

styled-components-website's Issues

Translations

We should make the documentation available in more languages! The setup is definitely not there to do this so there'll be a lot of changes necessary in the website to get set up with the tooling. Does anybody have experience with this?


The biggest wins based on where tweets seem to be coming from would likely be:

  • Japanese (!)
  • Chinese (!)
  • German (I can cover this one)
  • Spanish?
  • Portuguese?
  • Hindi?

Separate tooling pages

Since the tooling docs are quite long, they don't really make sense to all live on a single huge page. I think it'd make sense to move them all to actually separate pages:

  • /docs/tooling/babel-plugin
  • /docs/tooling/stylelint
  • etc.

/cc @philpl wdyt?

Ecosystem page

Rather than having a huge list of related libraries in our README we should move that to the website! Could be structured into "one-off npm components you can use built with s-c", "component libraries" "grids" and "others" or something.

Update / Improve documentation narrative & content

Most of the content right now is from theβ€”fairly outdatedβ€”docs in the styled-components repo.

It'd be great to take the time to think about the sections, narrative, missing content, current content, etc.

Scrolling broken in docs

Hi guys,

stumpled upon the beautiful website today - love it! Unfortunately, there's a nasty bug - at least in Mac OS, Chrome Version 60.0.3112.101 (Official Build) (64-bit):

If you scroll down the content completely, you can't scroll in the nav section anymore.

I've created a screencast to highlight this problem:

screencast

Unfortunately, you can't see when I'm using my scroll wheel on the mouse - but it should be straight forward to reproduce the issue on your machine:

  1. open up https://www.styled-components.com/docs
  2. scroll the content area once
  3. try to scroll the navigation area
  4. πŸ’₯ - nothing happens

If you select so much text in the navigation area that it's start scrolling based on your selection, it's free again and it's able to scroll the section. Until: You scroll the content once again! :)

Add Analytics

micro-analytics is nice and all, but doesn't quite give us what we need and I don't have time to improve it further.

Let's switch to something else. I'd love for the stats to be public, if that's not possible because it doesn't exist let's just use Google Analytics because it's easy?

Move website to main repo when finished

I'd hate for the docs to be outdated because you can't update the docs and code at the same time. I'd prefer the website (when finished) to live in the same repo as the code if at all possible!

Documentation: more on React Native (values, Animated)

I'm new on using styled-components. I'm working with it on a React Native app. I've read all documentation and React Native section is maybe lacking of some little help It would be useful.

  • Emphasize on styled.Component is an alias for styled(Component), in case Component is not built into the aliases (see styled-components/styled-components#1027)

  • Interpolation can mix more than text/numeric values/theme.props and also include other expressions (since they're actually ES template strings), e.g.:

    styled.View`
      border-width: ${StyleSheet.hairlineWidth};
    `;
  • Animations section is made for web and it is clarified in React Native section: as an improvement it could link to Animations documentation, and mention you can use Animated.createAnimatedComponent() with styled.Component: Animated.createAnimatedComponent(styled.Component)

  • (this is still confusing for me) By the end of React Native section it is mentioned that now it uses percentages, which is fine, but It was really confusing for me when I tried to use unitless values (since I've used RN StyleSheet before) and styled-component was expecting a unit like px. Maybe it should emphasize on using units just like on CSS.

Hope this helps to improve documentation :)

Improve SEO

I know, I know, who needs SEO anyways? But if you google the site this is what you get:

screen shot 2017-08-28 at 19 53 27

None of the content, and only the top-level pages are linked. (not even the sub-sections are there) Would much appreciate help so people can find the content on the website more easily!

Add eslint and prettier to repo

Yellow!

I was thinking maybe adding eslint and prettier would be a good idea here since the website has a lot of components and things can get messy with different ways of writing code

Sent from my Bq Aquaris M5 using FastHub

FAQ: Why you should to avoid declare styled component in render method

Sometimes I see in different PRs something like that:

const Header = () => {
  const Title = styled.h1`
    font-size: 10px;
  `

  return (
    <div>
      <Title />
    </div>
  )
}

As I understand classes for this component will be generated only in runtime in browser and even SSR doesn't help. It's pretty hard to describe this all the time, so it will be great to have a link in official documentation.

FAQ links don't point to the right sections.

The FAQ links "Support for nesting" and "Referring to other components" take you to the FAQ, but they don't jump to the appropriate section:

https://www.styled-components.com/docs/faqs#referring-to-other-components

This is because the <SectionLayout> title doesn't match; the FAQ item headings are all question-format, but it looks like it just uses the dash-case version of the menu item for the hash anchor links.

A fancy solution could be to update docs.json to support a "display" heading as well as a "hash" string, for navigation. More simply, we could just update the links to match.

Add Tooling Section

We want to create a Tooling section, where we are going to add:

  • babel-plugin-styled-components (now under Advanced, see: /pull/62)
  • jest-styled-components

Perhaps we can add className also to the example?

Perhaps the key aspect of SC is elegance in splitting style/markup. And since many projects still use old CSS classes that are shared for the whole project, class names will remain for many projects.

The new .attr chainable method is awesome for this use case & I think adding a className in the provided example may be a good idea. Something like

import styled from 'styled-components';

const Input = styled.input.attrs({
  type: 'text',
  size: props => props.small ? 3 : 8,
  className: 'pa4 ba bg--black-80',
})`
  background: palevioletred;
  border-radius: 3px;
  border: none;
  color: white;
  padding: ${props => props.padding}
`;

.attrs docs needs clarification

https://www.styled-components.com/docs/basics#attaching-additional-props

The attrs function passes all attributes directly to the dom node.
so it should only be used with "safe" values that won't trigger html incompatibilities.

In the docs the word "props" is being used.

"It allows you to attach additional props (or "attributes") to a component."

And it implies that it should be used for organizing the data logic before the css expression.
The example actually uses them for something similar to "defaultProps".
If you use it like the docs tells you to you will suddenly generate tons of react warnings.

The docs should be clearer about this function intended behavior to prevent these confusions.

PS:
The behavior that the documentation implies is actually really helpful and the impossibility to use it like this creates the need for workarounds like creating wrapper-components. Would creating a .props functionality that behaves exactly like attrs but without the dom printing be something to consider? By creating wrapper components you're suddenly breaking the styled-components "flow" preventing further "extensions". With a props functionality tons of compositions would be possible.

Add documentation on imports

Just had a brief discussion here: #59

So either we:

  • Add some notes on imports in "Getting Started"
  • Add some notes to each helper in the API section
  • Add some notes here and there ( πŸ‘Ž )
  • Add an import functionality to react-live ( any ideas )

cc @TrevorBurnham @mxstbr

GitHub star button and count on homepage

Maybe there's a way to show a live star count and "Star" button on the homepage without using GitHub's huge default embed? Can we fetch the star count from the backend and cache it for 24 hours in memory or something like that?

Set up redirection for moved/renamed docs pages

We've now for the first time moved a section (babel plugin) to a different URL. But a slight rename can also change the URL dramatically, which leads to previous links being dead / unusable. Together with anchors this can become really annoying as it might not be immediately obvious that a section is missing.

We need to add some "stub" entries to the docs.json that set up some simple redirection to the new location. I think this is crucial not to frustrate readers over time πŸ‘

Add "Guides" section

We could use a more tutorial-like guides section for some longer topics.

  • Server-side rendering with Express (including setting up a build process?)
  • Setting up a codebase for success (stylelint + prettier + folder structure?)
  • Preact + styled-components
  • Inferno + styled-components
  • Other ideas?

Homepage has a lot of styles

For some reason the homepage ships a lot of styles (a few thousand lines) even though it should only serve the ones needed to render the homepage. Something's wrong, /cc @styled-components/core πŸ€”

Maybe that's due to Next.js and how it renders?

h/t @threepointone @AndrewIngram

Add Babel plugin

People will look in the DevTools, see the x-Asdf123 classnames and be turned off. Let's avoid that by using the Babel plugin.

Upgrade next to version 3 as soon as 3.0.7 is released

Currently we have a vendored version of next: https://github.com/styled-components/styled-components-website/blob/master/vendor/next-v2.4.8.tgz

This is to work around our styling problem that prevented us from wrapping the entire app. A fix was proposed here but wasn't merged for a long time: vercel/next.js#2010

Now that it was merged we can get rid of the vendored version and upgrade to v3, as soon as the fix lands in the next patch release

Separate .md files for markdown

Rather than have the markdown content as strings inside of JavaScript (which is annoying for escaping and highlighting, and might make translation tooling harder) we should be extending the webpack configuration with raw-loader, have .md files, import them and wrap them in react-markings!

We might even be able to do it automatically so that we don't have to do the wrapping manually for each .md file? There's gotta be a webpack plugin for that! πŸ˜‰

Translation tooling

With the volunteers in #70 and the changes in #74 the content is now in a markdown string and we should now be able to start translating the webpage.

React uses https://crowdin.com, which seems pretty good in terms of the workflow for translators and they offer a free unlimited account to OSS projects. What I'm not sure about is the workflow from the development side; how are changes going to get on the website, which format do the strings need to have, etc.

On top of that I'm not sure how we'd make that happen across the app, how we'd structure the repo, etc.

Any investigations/experiences here very helpful.

Figure out navigation

Right now, even on a large screen, large portions of the nav are cut off:

screen shot 2017-08-28 at 19 56 14

That's not good, and it'll only get worse as we add more content to the site. We should figure out a better way of doing navigation.

We need a top nav for the "big pages" that should persist across all pages. (Homepage, Docs, Docs -> Basics, Docs -> Advanced, Docs -> FAQ, Docs -> Tooling, etc) We'll then likely still need some sort of side nav for the docs pages to navigate within them.

Any design/layout ideas and implementations welcome!

Add site search

I love how the React and Flow docs do their search, I think that's using Algolia? We should have the search input on every page, so it'll likely have to sit in the nav bar at the top, ref #83.

For now it'd be fine to only live on docs pages in the sidebar though, don't let yourself be blocked by #83!

Update: There's a search component ready for the nav bar.

LiveEdit overflow

Hey guys, I have a proposition to improve docs.
In Regards to LiveEdit components where you can scroll inside.

The problem is when you scroll over top or bottom inside LiveEdit component, then you scroll with the whole page and you mess up your scroll position. Which seems super annoying to me.

Here is a demo if you don't know what I mean.
http://codepen.io/pavelsuraba/full/bWVoBO/

Anyway it's not hard to implement and I could fix that with HOC.

Would this change be welcomed?

Thanks.

The "documentation" button is broken

Hello, the "documentation" button is broken in production:

screen shot 2017-07-30 at 11 43 44

The classe names (sc-brqgnP dlxELr sc-bZQynM coTCuP) seem to be right, but the order on which they are applied is wrong:

screen shot 2017-07-30 at 11 45 22

I can't repro the issue on dev (master).

Improve docs homepage

The docs homepage right now mostly duplicates content from the nav and from the homepage:

screen shot 2017-08-28 at 19 56 14

We should figure out a better thing to do with it than just that. Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.