-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create Cutout and Window components
- Loading branch information
Showing
10 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { Cutout, Text, Window } from 'react95-native'; | ||
|
||
import Container from '../util/Container'; | ||
|
||
const CutoutExample = () => { | ||
return ( | ||
<Container> | ||
<Container.Section title='Usage:'> | ||
<Window style={{ padding: 12 }}> | ||
<Cutout style={{ height: 120 }}> | ||
<Text> | ||
React95 React95 React95 React95 React95 React95 React95 React95 | ||
React95 React95 | ||
</Text> | ||
<Text> | ||
React95 React95 React95 React95 React95 React95 React95 React95 | ||
React95 React95 | ||
</Text> | ||
<Text> | ||
React95 React95 React95 React95 React95 React95 React95 React95 | ||
React95 React95 | ||
</Text> | ||
<Text> | ||
React95 React95 React95 React95 React95 React95 React95 React95 | ||
React95 React95 | ||
</Text> | ||
</Cutout> | ||
</Window> | ||
</Container.Section> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default CutoutExample; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react-native'; | ||
|
||
import { testId } from './Cutout'; | ||
import { Cutout, Text } from '..'; | ||
|
||
describe('<Cutout />', () => { | ||
it('should render children', () => { | ||
const { getByTestId } = render( | ||
<Cutout> | ||
<Text>This is a Cutout</Text> | ||
</Cutout> | ||
); | ||
|
||
expect(getByTestId(testId)).toHaveTextContent('This is a Cutout'); | ||
}); | ||
|
||
it('should render custom styles', () => { | ||
const style = { padding: 12 }; | ||
|
||
const { getByTestId } = render( | ||
<Cutout style={style}> | ||
<Text>Potatoe</Text> | ||
</Cutout> | ||
); | ||
|
||
expect(getByTestId(testId)).toHaveStyle(style); | ||
}); | ||
}); |
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,49 @@ | ||
import React from 'react'; | ||
import { StyleSheet, View, ScrollView } from 'react-native'; | ||
|
||
import { border } from '../common/styles'; | ||
import { original as theme } from '../common/themes'; | ||
|
||
export const testId = 'cutout'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
// shadow?: boolean; | ||
style?: Object; | ||
}; | ||
|
||
const Cutout = ({ children, style = {} }: Props) => { | ||
return ( | ||
<ScrollView style={[styles.container, style]} testID={testId}> | ||
<View style={styles.beforeContainer}> | ||
<View style={styles.content}>{children}</View> | ||
</View> | ||
</ScrollView> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
...border.wellInverted, | ||
backgroundColor: theme.material, | ||
padding: 2, | ||
borderStyle: 'solid', | ||
lineHeight: 1.5 | ||
}, | ||
beforeContainer: { | ||
borderStyle: 'solid', | ||
borderWidth: 2, | ||
margin: -2, | ||
borderLeftColor: theme.borderDarkest, | ||
borderTopColor: theme.borderDarkest, | ||
borderRightColor: theme.borderLight, | ||
borderBottomColor: theme.borderLight | ||
// ${props => props.shadow && `box-shadow:${insetShadow};`} | ||
}, | ||
content: { | ||
width: '100%', | ||
padding: 4 | ||
} | ||
}); | ||
|
||
export default Cutout; |
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 @@ | ||
export { default } from './Cutout'; |
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,23 @@ | ||
import React from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import { border, box } from '../common/styles'; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
style?: Object; | ||
}; | ||
|
||
const Window = ({ children, style = {} }: Props) => { | ||
return <View style={[styles.container, style]}>{children}</View>; | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
padding: 4, | ||
...border.windowBorders, | ||
...box.default | ||
} | ||
}); | ||
|
||
export default Window; |
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 @@ | ||
export { default } from './Window'; |
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