This repository has been archived by the owner on Mar 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
81 deletions.
There are no files selected for viewing
48 changes: 19 additions & 29 deletions
48
src/lib/components/consignments/__stories__/consignments-bottom-aligned.story.tsx
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,37 +1,27 @@ | ||
import * as React from "react" | ||
import { View } from "react-native" | ||
import { Text, View } from "react-native" | ||
|
||
import { storiesOf } from "@storybook/react-native" | ||
import { camelCase } from "lodash" | ||
import Search from "../components/artist-search-results" | ||
import BottomAlignedButton, { BottomAlignedProps } from "../components/bottom-aligned-button" | ||
|
||
import Search, { ArtistQueryData } from "../components/artist-search-results" | ||
export const name = "Consignments - bottom aligned" | ||
export const component = BottomAlignedButton | ||
|
||
interface States { | ||
[name: string]: BottomAlignedProps | ||
} | ||
|
||
const query4Results: ArtistQueryData = { | ||
query: "bank", | ||
searching: false, | ||
results: [ | ||
artistGen("Ada Van Hoorebeke"), artistGen("Kathleen Adair Brown"), | ||
artistGen("Linda Adair"), artistGen("Hector Adalid"), | ||
], | ||
const withText = { | ||
children: [<Text>hi</Text>], | ||
onPress: () => "" , | ||
} | ||
|
||
export const allStates = [ | ||
{ "No query" : noQuery }, | ||
{ "Looking for new results" : queryNoResultsSearching }, | ||
{ "Found no results" : queryNoResults }, | ||
{ "Found one result" : query1Result }, | ||
{ "Found one result, and searching" : query1ResultSearching }, | ||
{ "Found two results" : query2Results }, | ||
{ "Found four results" : query4Results }, | ||
] | ||
const withSearchResults = { | ||
children: [<Search searching={false} query="Bank" results={null} />], | ||
onPress: () => "", | ||
} | ||
|
||
const stories = storiesOf("Consignments - Search") | ||
allStates.forEach(element => { | ||
const name = Object.keys(element)[0] | ||
stories.add(name, () => | ||
<View style={{flex: 1, backgroundColor: "black", padding: 20, marginTop: 60}}> | ||
<Search {...element[name]} /> | ||
</View>, | ||
) | ||
}) | ||
export const allStates: States[] = [ | ||
{ "With a Text element" : withText }, | ||
{ "With an Artist Search Results Component" : withSearchResults }, | ||
] |
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 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,45 @@ | ||
import "./consignments.story" | ||
import "./typography.story" | ||
|
||
import { storiesOf } from "@storybook/react-native" | ||
import * as React from "react" | ||
import { View } from "react-native" | ||
|
||
import * as bottomAlignedButton from "./consignments-bottom-aligned.story" | ||
import * as search from "./consignments-search.story" | ||
import * as todo from "./consignments-todo.story" | ||
|
||
// Just a quick interface so you know the API | ||
interface AutoStory { | ||
name: string, | ||
allStates: any[], | ||
component: any | ||
} | ||
|
||
// Converts a set of state and a component type into a set of stories | ||
const autoStories: AutoStory[] = [ | ||
search, | ||
bottomAlignedButton, | ||
todo, | ||
] | ||
|
||
const Wrapper = (props) => | ||
<View style={{flex: 1, backgroundColor: "black", padding: 20, marginTop: 60}}> | ||
{props.children} | ||
</View> | ||
|
||
// Allows stories to strictly be about their state and the | ||
// component itself. | ||
|
||
autoStories.forEach(storybook => { | ||
const stories = storiesOf(storybook.name) | ||
|
||
storybook.allStates.forEach(element => { | ||
const name = Object.keys(element)[0] | ||
stories.add(name, () => | ||
<Wrapper> | ||
<storybook.component {...element[name]} /> | ||
</Wrapper>, | ||
) | ||
}) | ||
}) |
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 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