-
Notifications
You must be signed in to change notification settings - Fork 14
Add Upleveled slides and tweak some excerices #61
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
Draft
okonet
wants to merge
11
commits into
master
Choose a base branch
from
upleveled
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2feacdf
WIP on upleveled presentation
27dba90
Fix the example
be9f93f
Update slides for Upleveled lecture
44d6b77
Fix Image example
2ec1b38
Update exercise 5
869a1d0
Export all primitives via index.js
c6dff52
Add support for SC and imports in the styleguide examples
d5fe6f7
Update slides
595dbb6
Update slides
30cf9b4
Add link to GitHub
3454438
Update excerice code
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
borderColor="grey.5" | ||
> | ||
<Box | ||
pb={5} | ||
py={5} | ||
mb={5} | ||
borderBottom="thin" | ||
borderColor="grey.4" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export { default as Box } from './primitives/Box'; | ||
export { default as Button } from './primitives/Button'; | ||
export { default as Card } from './primitives/Card'; | ||
export { default as Flex } from './primitives/Flex'; | ||
export { default as Grid } from './primitives/Grid'; | ||
export { default as Heading } from './primitives/Heading'; | ||
export { default as Icon } from './primitives/Icon'; | ||
export { default as Image } from './primitives/Image'; | ||
export { default as Input } from './primitives/Input'; | ||
export { default as Link } from './primitives/Link'; | ||
export { default as Select } from './primitives/Select'; | ||
export { default as Stack } from './primitives/Stack'; | ||
export { default as Text } from './primitives/Text'; | ||
export { default as VisuallyHidden } from './primitives/VisuallyHidden'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { | ||
Box, | ||
Button, | ||
Flex, | ||
Grid, | ||
Heading, | ||
Input, | ||
Link, | ||
Stack, | ||
Text, | ||
} from '../../components'; | ||
|
||
export default () => { | ||
return <form>Your markup here</form>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```jsx | ||
<LoginForm /> | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,31 @@ | ||
## 5.1 Using layout and basic primitive to compose UI patterns | ||
## 5.1 Creating a login form using primitives | ||
|
||
In the previous exercise we learned how to manage whitespace around our primitives. Now it's time to use what we learned and create an application specific component. | ||
|
||
### The result | ||
|
||
```jsx noeditor | ||
import SubscriptionForm from '../../../src/components/patterns/SubscriptionForm'; | ||
|
||
<SubscriptionForm | ||
id="sf1" | ||
email="" | ||
onSubmit={() => {}} | ||
onEmailChange={() => {}} | ||
/>; | ||
``` | ||
|
||
### The task | ||
|
||
1. Create a `SubscriptionForm` component using the `Grid` component. | ||
2. The layout should be responsive and the button should be placed below the input field on a narrow screen. | ||
|
||
**Hint:** Use `grid-template-columns` CSS property for responsiveness, like this: `gridTemplateColumns={['1fr', '1fr auto']}`. | ||
|
||
<details> | ||
<summary>Solution</summary> | ||
|
||
```js {"file": "solutions/5.1.js", "static": true} | ||
``` | ||
|
||
</details> | ||
|
||
## 5.2 Creating a new page using primitives | ||
|
||
Using `Box` and `Flex` components we can create really complex layouts without writing custom CSS. And since the values for the spacing are coming from our [spacing scale](https://cdds.netlify.com/styleguide/#/Foundation?id=spacing) we can be sure our layouts are consistent across the whole application. | ||
|
||
We can even create full pages. Let’s try to create a new login page four our app. | ||
Let’s create a login form four our app. | ||
|
||
### The result | ||
|
||
```jsx noeditor | ||
import Box from '../../components/primitives/Box'; | ||
import Flex from '../../components/primitives/Flex'; | ||
import Heading from '../../components/primitives/Heading'; | ||
import Button from '../../components/primitives/Button'; | ||
import Link from '../../components/primitives/Link'; | ||
import Text from '../../components/primitives/Text'; | ||
import Input from '../../components/primitives/Input'; | ||
|
||
<form> | ||
<Heading mb={4}>Login</Heading> | ||
<Text as="label" display="block" mb={3}> | ||
<Box mb={2}>Username</Box> | ||
<Input type="text" /> | ||
</Text> | ||
<Text as="label" display="block" mb={4}> | ||
<Box mb={2}>Password</Box> | ||
<Input type="password" /> | ||
</Text> | ||
<Box mb={4}> | ||
<Link href="#">Forgot your password?</Link> | ||
</Box> | ||
<Button>Log in</Button> | ||
</form>; | ||
```js noeditor | ||
import LoginForm from './final/LoginForm'; | ||
<LoginForm/> | ||
``` | ||
|
||
### The task | ||
|
||
1. Create a `LoginPage` component. | ||
1. Create a `LoginForm` component. | ||
2. Use only primitives for layout, whitespace (`Box`, `Flex`, `Grid`, and `Stack`) and text (`Text`, `Heading`, `Button`, and `Link`). | ||
3. The layout should be responsive and the labels should be placed above input fields on a narrow screen. | ||
|
||
**Hint:** Use arrays for responsiveness, like this: `gridTemplateColumns={['1fr', '1fr auto']}`. | ||
|
||
2. Use only primitives for layout, whitespace (`Box`, `Flex`, `Grid`, and `Stack`) and text (`Text`, `Heading` and `Link`). | ||
|
||
<details> | ||
<summary>Solution</summary> | ||
|
||
```js {"file": "solutions/5.2.js", "static": true} | ||
```js {"file": "./final/LoginForm.js", "static": true} | ||
``` | ||
|
||
</details> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import { | ||
Heading, | ||
Text, | ||
Box, | ||
Flex, | ||
Grid, | ||
Input, | ||
Link, | ||
Button, | ||
Stack, | ||
} from '../../../components'; | ||
|
||
export default () => { | ||
return ( | ||
<Stack as="form" gridGap={[4,5]} padding={[4,5]} bg="muted"> | ||
<Heading size="lg">Login please</Heading> | ||
<Grid gridGap={4} gridTemplateColumns={["1fr", "auto 1fr"]} alignItems="center"> | ||
<Text as="label" htmlFor="username"> | ||
Username | ||
</Text> | ||
<Input | ||
type="email" | ||
name="username" | ||
id="username" | ||
placeholder="[email protected]" | ||
autoFocus | ||
/> | ||
</Grid> | ||
<Grid gridGap={4} gridTemplateColumns={["1fr", "auto 1fr"]} alignItems="center"> | ||
<Text as="label" htmlFor="password"> | ||
Password | ||
</Text> | ||
<Input type="password" name="password" id="password" /> | ||
</Grid> | ||
<Flex flexDirection={["column", "row"]}> | ||
<Box mr={[0, 4]}> | ||
<Button type="submit" variant="primary"> | ||
Log in | ||
</Button> | ||
</Box> | ||
<Box ml={[0, "auto"]}> | ||
<Link href="#">Forgot your password?</Link> | ||
</Box> | ||
</Flex> | ||
</Stack> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These are default options, maybe we need to upgrade Styleguidist?
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.
Good to know I'll drop it!