Skip to content
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

Empty component #91

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const App = () => {
- [ ] Collapse
- [ ] CountDown
- [ ] Divider
- [ ] Empty
- [x] Empty
- [ ] ImagePreview
- [ ] Lazyload
- [ ] List
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vant-react",
"version": "0.3.0",
"version": "1.0.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 0.3.1

"description": "Lightweight Mobile UI Components built in React & Typescript, inspired by Vant: https://youzan.github.io/vant",
"author": "mxdi9i7",
"license": "MIT",
Expand Down
8 changes: 2 additions & 6 deletions src/components/Empty/index.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// @import '../../styles/colors.scss';
// @import '../../styles/spacing.scss';
// @import '../../styles/typography.scss';
// @import '../../styles/opacity.scss';
@import '../../styles/variables.scss';
@import '../../styles/typography.scss';

$baseClass: 'vant-button';

$baseClass: 'vant-empty';

.#{$baseClass} {
display: flex;
Expand Down
60 changes: 31 additions & 29 deletions src/components/Empty/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,36 @@ export const ImageType = () => {

return (
<div className='storybook__container empty'>
<Button
onClick={() => {
setShowType('error');
}}
text='Error'
type='primary'
/>
<Button
onClick={() => {
setShowType('network');
}}
text='Network'
type='info'
/>
<Button
onClick={() => {
setShowType('search');
}}
text='Search'
type='warning'
/>
<Button
onClick={() => {
setShowType('custom');
}}
text='Custom'
type='danger'
/>
<div>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this div, we can use <></> fragments to enclose the buttons

<Button
onClick={() => {
setShowType('error');
}}
text='Error'
type='primary'
/>
<Button
onClick={() => {
setShowType('network');
}}
text='Network'
type='info'
/>
<Button
onClick={() => {
setShowType('search');
}}
text='Search'
type='warning'
/>
<Button
onClick={() => {
setShowType('custom');
}}
text='Custom'
type='danger'
/>
</div>
{showType === 'error' && (
<Empty image='error' description='description' />
)}
Expand All @@ -78,7 +80,7 @@ export const CustomImage = () => (
</div>
);

export const BottomContent = () => (
export const CustomBottomContent = () => (
<div className='storybook__container empty'>
<Empty
bottom={
Expand Down
7 changes: 2 additions & 5 deletions src/components/Empty/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React from 'react';

import classnames from '../../utils/classNames';

import { Props } from './types';

import './index.scss';
import { Network } from './Network';

const baseClass = 'vant-button';
const baseClass = 'vant-empty';
const PRESET_IMAGES = ['error', 'search', 'default'];

// TODO: custom imageSize
// TODO: bottom & image & description solts
// TODO: bottom & image & description slots
export default function Empty({
description,
image = 'default',
Expand Down
4 changes: 4 additions & 0 deletions src/styles/stories.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ body {
height: 200px;
}
}

&.empty {
flex-direction: column;
}
}
.slider-container {
display: flex;
Expand Down