diff --git a/package.json b/package.json
index ea9214fe7..b582338c5 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "vant-react",
- "version": "0.0.1",
+ "version": "0.0.3",
"description": "Lightweight Mobile UI Components built in React & Typescript, inspired by Vant: https://youzan.github.io/vant",
"author": "mxdi9i7",
"license": "MIT",
diff --git a/src/components/Button/index.scss b/src/components/Button/index.scss
index 5d24d49f0..cc1da4cdc 100644
--- a/src/components/Button/index.scss
+++ b/src/components/Button/index.scss
@@ -13,7 +13,6 @@ a.#{$baseClass} {
justify-content: center;
align-items: center;
position: relative;
- box-sizing: border-box;
color: $dark-text;
background-color: $default;
padding: 0 $padding-sm;
diff --git a/src/components/Button/stories/index.stories.tsx b/src/components/Button/index.stories.tsx
similarity index 95%
rename from src/components/Button/stories/index.stories.tsx
rename to src/components/Button/index.stories.tsx
index cea413822..806b229f8 100644
--- a/src/components/Button/stories/index.stories.tsx
+++ b/src/components/Button/index.stories.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import Button from '../';
-import '../../../styles/stories.scss';
+import Button from '.';
+import '../../styles/stories.scss';
export default {
title: 'Button',
@@ -124,5 +124,3 @@ export const ButtonAction = () => (
);
-
-// export const Emoji = () => ;
diff --git a/src/components/Icons/index.tsx b/src/components/Icons/index.tsx
index e5e9be666..16fe4bd44 100644
--- a/src/components/Icons/index.tsx
+++ b/src/components/Icons/index.tsx
@@ -35,8 +35,7 @@ export default function Icon({
const iconProps = {
className: `${classPrefix} ${classPrefix}-${name}`,
style: {
- fontSize: '28px',
- color: '#000'
+ fontSize: '28px'
}
};
@@ -57,7 +56,6 @@ export default function Icon({
});
}
- console.log(dot, badge);
return (
diff --git a/src/components/Navbar/index.scss b/src/components/Navbar/index.scss
new file mode 100644
index 000000000..80de4cea2
--- /dev/null
+++ b/src/components/Navbar/index.scss
@@ -0,0 +1,57 @@
+@import '../../styles/colors.scss';
+@import '../../styles/spacing.scss';
+@import '../../styles/variables.scss';
+@import '../../styles/typography.scss';
+
+$baseClass: 'vant-navbar';
+
+nav.#{$baseClass} {
+ position: relative;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ background-color: $default;
+ height: $navbar-height;
+ width: 100%;
+
+ .#{$baseClass}__title {
+ @include nav-title;
+ position: absolute;
+ left: 50%;
+ top: 50%;
+ transform: translate(-50%, -50%);
+ }
+
+ .#{$baseClass}__left,
+ .#{$baseClass}__right {
+ @include nav-link;
+ display: flex;
+ align-items: center;
+ padding: 0 $space-lg;
+ cursor: pointer;
+
+ .vant-icon__container {
+ height: auto;
+ width: auto;
+ .vant-icon {
+ color: $info;
+ }
+ }
+ }
+
+ .#{$baseClass}__left {
+ .vant-icon {
+ margin-right: $space-sm;
+ }
+ }
+ .#{$baseClass}__right {
+ .vant-icon {
+ margin-left: $space-sm;
+ }
+ }
+
+ &__fixed {
+ position: fixed;
+ top: 0;
+ }
+}
diff --git a/src/components/Navbar/index.stories.tsx b/src/components/Navbar/index.stories.tsx
new file mode 100644
index 000000000..03e26e514
--- /dev/null
+++ b/src/components/Navbar/index.stories.tsx
@@ -0,0 +1,64 @@
+import React from 'react';
+import Navbar from '.';
+import '../../styles/stories.scss';
+
+export default {
+ title: 'Navbar',
+ component: Navbar
+};
+
+export const NavbarTitle = () => (
+
+
+
+);
+
+export const NavbarLeftAndRightText = () => (
+
+
+
+
+
+);
+
+export const NavbarFixed = () => (
+
+
+
+);
+
+export const NavbarWithLongTitle = () => (
+
+
+
+);
+
+export const NavbarClickHandler = () => (
+
+ alert(e.target.innerHTML + ' Left Click')}
+ clickRight={(e) => alert(e.target.innerHTML + ' Right Click')}
+ />
+
+);
diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx
new file mode 100644
index 000000000..a39dfaafd
--- /dev/null
+++ b/src/components/Navbar/index.tsx
@@ -0,0 +1,61 @@
+import React, { ReactElement } from 'react';
+
+import Icon from '../Icons';
+
+import classnames from '../../utils/classNames';
+
+import './index.scss';
+
+interface Props {
+ title?: string;
+ leftText?: string;
+ rightText?: string;
+ border?: boolean;
+ fixed?: boolean;
+ leftIcon?: string;
+ rightIcon?: string;
+ clickLeft?: Function;
+ clickRight?: Function;
+ zIndex?: number;
+}
+
+const baseClass = 'vant-navbar';
+
+// TODO: Enable placeholder: Whether to generate a placeholder element when fixed
+
+export default function Navbar({
+ title,
+ leftText,
+ rightText,
+ leftIcon,
+ rightIcon,
+ border,
+ fixed,
+ zIndex = 1,
+ clickLeft = () => {},
+ clickRight = () => {}
+}: Props): ReactElement {
+ const navProps = {
+ style: {
+ zIndex
+ },
+ className: classnames(baseClass, [{ border }, { fixed }])
+ };
+
+ const NAV_ICON_SIZE = '16px';
+
+ return (
+
+ );
+}
diff --git a/src/styles.module.css b/src/styles.module.css
deleted file mode 100644
index 41006b532..000000000
--- a/src/styles.module.css
+++ /dev/null
@@ -1,9 +0,0 @@
-/* add css module styles here (optional) */
-
-.test {
- margin: 2em;
- padding: 0.5em;
- border: 2px solid #000;
- font-size: 2em;
- text-align: center;
-}
diff --git a/src/styles/global.scss b/src/styles/global.scss
index 1236d8edf..b13e5470c 100644
--- a/src/styles/global.scss
+++ b/src/styles/global.scss
@@ -1,3 +1,6 @@
* {
box-sizing: border-box;
+ font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,
+ Segoe UI, Arial, Roboto, 'PingFang SC', 'Hiragino Sans GB',
+ 'Microsoft Yahei', sans-serif;
}
diff --git a/src/styles/stories.scss b/src/styles/stories.scss
index b67e05966..1b1bcfbbc 100644
--- a/src/styles/stories.scss
+++ b/src/styles/stories.scss
@@ -26,6 +26,14 @@ body {
}
}
+ nav {
+ margin-bottom: 20px;
+
+ .vant-icon__container {
+ margin: 0;
+ }
+ }
+
button,
a {
margin-right: 20px;
diff --git a/src/styles/typography.scss b/src/styles/typography.scss
index a4d923a24..d5333ce99 100644
--- a/src/styles/typography.scss
+++ b/src/styles/typography.scss
@@ -1,5 +1,26 @@
+@import './global.scss';
+@import './colors.scss';
+
@mixin normal {
font-size: 14px;
line-height: 1.2;
text-align: center;
}
+
+@mixin nav-title {
+ font-size: 16px;
+ text-transform: capitalize;
+ font-weight: 500;
+ color: $dark-text;
+ overflow-x: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ max-width: 60%;
+}
+
+@mixin nav-link {
+ font-size: 14px;
+ font-weight: 100;
+ line-height: 21px;
+ color: $info;
+}
diff --git a/src/styles/variables.scss b/src/styles/variables.scss
index 1d8ab6cfd..aa7cbe65a 100644
--- a/src/styles/variables.scss
+++ b/src/styles/variables.scss
@@ -6,6 +6,9 @@ $loader-circular-duration: 1.4s;
// buttons
$button-height: 44px;
+// navbar
+$navbar-height: 56px;
+
// icons
$icon-container-size: 32px;
$icon-dot-size: 8px;