kettanaito / atomic-layout

Build declarative, responsive layouts in React using CSS Grid.
https://redd.gitbook.io/atomic-layout
MIT License
1.13k stars 33 forks source link

Add interactive examples to README #256

Open kettanaito opened 4 years ago

kettanaito commented 4 years ago

What:

The README should include the list of examples. Each example item should contain:

  1. A thumbnail image.
  2. A title.
  3. A short description on the example's purpose.
  4. A link to the interactive playground (Codesandbox) with the respective example.

Why:

Carefully designed, a list of examples may substitute documentation at its entirety. At least it's a great illustrative showcase for practical learners and beyond.

How:

I suggest to split examples into sections based on the complexity level.

Basics

Intermediate

Advanced

dandelionadia commented 4 years ago

I will edit this comment if I finish more examples.

Basics

kettanaito commented 4 years ago

I'll describe the intermediate examples in more detail below.

Intermediate examples

Conditional rendering (Only)

Need to come up with a practical example of conditional rendering. Maybe a burger menu in header?

Custom configuration

The intention is to illustrate how to configure your layout consistently using Layout.configure.

// src/index.jsx
import Layout from 'atomic-layout'

Layout.configure({
  defaultUnit: 'rem',
  breakpoints: {
    mobile: {
      maxWidth: '570px'
    },
    tablet: {
      minWidth: '571px',
     maxWidth: '960px'
    },
    desktop: {
      minWidth: '961px'
    }
  }
})

After the configuration is applied, demonstrate how it works by writing a simple Box/Composition and using those custom breakpoints for responsive props (i.e. <Composition areasDesktop={...} />).

Using global layout settings

Show an example of a styled component that declares an explicit media query referencing to values from Atomic Layout.

dandelionadia commented 4 years ago

I did two examples to the Intermediate part. Could you look at it please and tell me what you do not like and what do you want to change?

https://codesandbox.io/s/conditional-rendering-4k90o https://codesandbox.io/s/custom-configuration-d01ku

kettanaito commented 4 years ago

@dandelionadia, thank you for providing those! Look amazing. If you don't mind, I'll list a few comments to the examples you've prepared.

Conditional rendering

Screen Shot 2020-04-20 at 12 13 00

Custom configuration

Warning: Each child in a list should have a unique "key" prop.
kettanaito commented 4 years ago

@dandelionadia, thank you for the fixes! Please, if I may, there are a few more comments.

Conditional rendering

Custom configuration

kettanaito commented 4 years ago

Just merged the intermediate examples section to master!

Huge thanks once more, @dandelionadia! Looking forward to those advanced ones :)