chore: remove useless code

This commit is contained in:
fushen 2019-12-26 15:42:25 +08:00
parent 0715355fef
commit a172553dfb
7 changed files with 230 additions and 325 deletions

View File

@ -1,9 +1,9 @@
import { createElement } from 'rax';
import renderer from 'rax-test-renderer';
import { App } from './index';
import { Welcome } from './index';
test('App render correctly', () => {
const tree = renderer.create(<App />).toJSON();
test('Welcome render correctly', () => {
const tree = renderer.create(<Welcome />).toJSON();
expect(tree).toMatchSnapshot();
});

View File

@ -1,11 +1,47 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`App render correctly 1`] = `
exports[`Welcome render correctly 1`] = `
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"Welcome to storybook for Rax",
],
"style": Object {
"fontSize": 40,
"fontWeight": "bold",
"lineHeight": "80px",
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
Object {
"attributes": Object {
"class": "rax-image ",
"fallbackSource": Object {
"uri": "https://user-images.githubusercontent.com/677114/49848760-999e7d00-fe11-11e8-978f-264ea31f6739.png",
},
"resizeMode": "cover",
"src": "./rax-logo.png",
},
"eventListeners": Object {
"error": [Function],
"load": [Function],
},
"style": Object {
"height": 100,
"margin": "0 auto",
"objectFit": "cover",
"width": 100,
},
"tagName": "IMG",
},
Object {
"attributes": Object {
"class": "rax-view",
@ -16,29 +52,153 @@ Object {
"class": "rax-text ",
},
"children": Array [
"Welcome to Rax",
"This is a UI component dev environment for your Rax app.",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
Object {
"attributes": Object {
"class": "rax-text ",
"class": "rax-view",
},
"children": Array [
"To get started, edit src/components/App.js and save to reload.",
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"We&#x27;ve added some basic stories inside the &#x27;src/stories&#x27; directory. A story is a single state of one or more UI components. You can have as many stories as you want. (Basically a story is like a visual test case.)",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"webkitLineClamp": undefined,
"marginBottom": 10,
},
"tagName": "SPAN",
"tagName": "DIV",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"See these sample",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
Object {
"attributes": Object {
"type": "button",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"button",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
],
"tagName": "BUTTON",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"for a component called &#x27;Button&#x27;.",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"Just like that, you can add your own components as stories. You can also edit those components and see changes right away. (Try editing the &#x27;Button&#x27; stories located at &#x27;src/stories/index.js&#x27; .)",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
],
"style": Object {
"fontFamily": "\\"Helvetica Neue\\", Helvetica, \\"Segoe UI\\", Arial, freesans, sans-serif",
"margin": 15,
},
"tagName": "DIV",
}
`;

View File

@ -1,27 +0,0 @@
.app {
flex: 1;
justify-content: center;
align-items: center;
background-color: #222;
color: white;
padding: 40px;
}
.appHeader {
height: 160;
padding: 40px;
}
.appBanner, .appIntro {
text-align: center;
}
.appBanner {
font-size: 40;
color: white;
}
.appIntro {
margin-top: 40;
font-size: 20;
}

View File

@ -1,15 +1,67 @@
/* eslint-disable react/prop-types */
import { createElement } from 'rax';
import View from 'rax-view';
import Text from 'rax-text';
import styles from './index.css';
import Image from 'rax-image';
export const App = () => (
<View style={styles.app}>
<View style={styles.appHeader}>
<Text style={styles.appBanner}>Welcome to Rax</Text>
</View>
<Text style={styles.appIntro}>
To get started, edit src/components/App.js and save to reload.
</Text>
const Main = ({ children, ...props }) => (
<View
{...props}
style={{
margin: 15,
fontFamily: '"Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif',
}}
>
{children}
</View>
);
const P = ({ children, ...props }) => (
<View {...props} style={{ marginBottom: 10 }}>
<Text style={{ fontSize: 12 }}>{children}</Text>
</View>
);
const Title = ({ children, ...props }) => (
<Text {...props} style={{ fontSize: 40, lineHeight: '80px', fontWeight: 'bold' }}>
{children}
</Text>
);
export const Welcome = ({ showApp }) => (
<Main>
<Title>Welcome to storybook for Rax</Title>
<Image
source={{
uri: './rax-logo.png',
}}
fallbackSource={{
uri:
'https://user-images.githubusercontent.com/677114/49848760-999e7d00-fe11-11e8-978f-264ea31f6739.png',
}}
style={{
width: 100,
height: 100,
margin: '0 auto',
}}
resizeMode="cover"
/>
<P>This is a UI component dev environment for your Rax app.</P>
<P>
We've added some basic stories inside the 'src/stories' directory. A story is a single state
of one or more UI components. You can have as many stories as you want. (Basically a story is
like a visual test case.)
</P>
<P>See these sample</P>
<button onPress={showApp} type="button">
<P>button</P>
</button>
<P>for a component called 'Button'.</P>
<P>
Just like that, you can add your own components as stories. You can also edit those components
and see changes right away. (Try editing the 'Button' stories located at
'src/stories/index.js' .)
</P>
</Main>
);

View File

@ -1,9 +0,0 @@
import { createElement } from 'rax';
import renderer from 'rax-test-renderer';
import { Welcome } from './index';
test('Welcome render correctly', () => {
const tree = renderer.create(<Welcome />).toJSON();
expect(tree).toMatchSnapshot();
});

View File

@ -1,204 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Welcome render correctly 1`] = `
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"Welcome to storybook for Rax",
],
"style": Object {
"fontSize": 40,
"fontWeight": "bold",
"lineHeight": "80px",
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
Object {
"attributes": Object {
"class": "rax-image ",
"fallbackSource": Object {
"uri": "https://user-images.githubusercontent.com/677114/49848760-999e7d00-fe11-11e8-978f-264ea31f6739.png",
},
"resizeMode": "cover",
"src": "./rax-logo.png",
},
"eventListeners": Object {
"error": [Function],
"load": [Function],
},
"style": Object {
"height": 100,
"margin": "0 auto",
"objectFit": "cover",
"width": 100,
},
"tagName": "IMG",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"This is a UI component dev environment for your Rax app.",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"We&#x27;ve added some basic stories inside the &#x27;src/stories&#x27; directory. A story is a single state of one or more UI components. You can have as many stories as you want. (Basically a story is like a visual test case.)",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"See these sample",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
Object {
"attributes": Object {
"type": "button",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"button",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
],
"tagName": "BUTTON",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"for a component called &#x27;Button&#x27;.",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
Object {
"attributes": Object {
"class": "rax-view",
},
"children": Array [
Object {
"attributes": Object {
"class": "rax-text ",
},
"children": Array [
"Just like that, you can add your own components as stories. You can also edit those components and see changes right away. (Try editing the &#x27;Button&#x27; stories located at &#x27;src/stories/index.js&#x27; .)",
],
"style": Object {
"fontSize": 12,
"webkitLineClamp": undefined,
},
"tagName": "SPAN",
},
],
"style": Object {
"marginBottom": 10,
},
"tagName": "DIV",
},
],
"style": Object {
"fontFamily": "\\"Helvetica Neue\\", Helvetica, \\"Segoe UI\\", Arial, freesans, sans-serif",
"margin": 15,
},
"tagName": "DIV",
}
`;

View File

@ -1,67 +0,0 @@
/* eslint-disable react/prop-types */
import { createElement } from 'rax';
import View from 'rax-view';
import Text from 'rax-text';
import Image from 'rax-image';
const Main = ({ children, ...props }) => (
<View
{...props}
style={{
margin: 15,
fontFamily: '"Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif',
}}
>
{children}
</View>
);
const P = ({ children, ...props }) => (
<View {...props} style={{ marginBottom: 10 }}>
<Text style={{ fontSize: 12 }}>{children}</Text>
</View>
);
const Title = ({ children, ...props }) => (
<Text {...props} style={{ fontSize: 40, lineHeight: '80px', fontWeight: 'bold' }}>
{children}
</Text>
);
export const Welcome = ({ showApp }) => (
<Main>
<Title>Welcome to storybook for Rax</Title>
<Image
source={{
uri: './rax-logo.png',
}}
fallbackSource={{
uri:
'https://user-images.githubusercontent.com/677114/49848760-999e7d00-fe11-11e8-978f-264ea31f6739.png',
}}
style={{
width: 100,
height: 100,
margin: '0 auto',
}}
resizeMode="cover"
/>
<P>This is a UI component dev environment for your Rax app.</P>
<P>
We've added some basic stories inside the 'src/stories' directory. A story is a single state
of one or more UI components. You can have as many stories as you want. (Basically a story is
like a visual test case.)
</P>
<P>See these sample</P>
<button onPress={showApp} type="button">
<P>button</P>
</button>
<P>for a component called 'Button'.</P>
<P>
Just like that, you can add your own components as stories. You can also edit those components
and see changes right away. (Try editing the 'Button' stories located at
'src/stories/index.js' .)
</P>
</Main>
);