Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: commit file name case change #2
- Loading branch information
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
app/react-native/src/preview/components/OnDeviceUI/addons/List.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { ScrollView } from 'react-native'; | ||
import styled from '@emotion/native'; | ||
import { Collection } from '@storybook/addons'; | ||
import Button from '../navigation/Button'; | ||
|
||
const Container = styled.View(({ theme }) => ({ | ||
flexDirection: 'row', | ||
borderBottomWidth: 1, | ||
borderBottomColor: theme.borderColor || '#e6e6e6', | ||
})); | ||
|
||
export interface Props { | ||
panels: Collection; | ||
addonSelected: string; | ||
onPressAddon: (id: string) => void; | ||
} | ||
|
||
export default class AddonList extends PureComponent<Props> { | ||
renderTab = (id: string, title: string) => { | ||
const { addonSelected, onPressAddon } = this.props; | ||
|
||
return ( | ||
<Button active={id === addonSelected} key={id} id={id} onPress={() => onPressAddon(id)}> | ||
{title.toUpperCase()} | ||
</Button> | ||
); | ||
}; | ||
|
||
render() { | ||
const { panels } = this.props; | ||
const addonKeys = Object.keys(panels); | ||
|
||
return ( | ||
<Container> | ||
<ScrollView showsHorizontalScrollIndicator={false} horizontal> | ||
{addonKeys.map((id) => { | ||
const { title } = panels[id]; | ||
// @ts-ignore | ||
const resolvedTitle = typeof title === 'function' ? title() : title; | ||
return this.renderTab(id, resolvedTitle); | ||
})} | ||
</ScrollView> | ||
</Container> | ||
); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
app/react-native/src/preview/components/OnDeviceUI/addons/Wrapper.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { View, ScrollView, StyleSheet } from 'react-native'; | ||
import { Collection } from '@storybook/addons'; | ||
|
||
export interface Props { | ||
panels: Collection; | ||
addonSelected: string; | ||
} | ||
|
||
const style = StyleSheet.create({ | ||
invisible: { | ||
height: 0, | ||
width: 0, | ||
opacity: 0, | ||
position: 'absolute', | ||
}, | ||
flex: { | ||
flex: 1, | ||
}, | ||
}); | ||
|
||
export default class Wrapper extends PureComponent<Props> { | ||
static defaultProps = { | ||
addonSelected: '', | ||
}; | ||
|
||
render() { | ||
const { panels, addonSelected } = this.props; | ||
|
||
const addonKeys = Object.keys(panels); | ||
|
||
return addonKeys.map((id) => { | ||
const selected = addonSelected === id; | ||
|
||
return ( | ||
<View key={id} style={selected ? style.flex : style.invisible}> | ||
<ScrollView>{panels[id].render({ active: selected, key: id })}</ScrollView> | ||
</View> | ||
); | ||
}); | ||
} | ||
} |