Skip to content

Commit

Permalink
Merge pull request #147 from hocgin/feature-scss
Browse files Browse the repository at this point in the history
Feature scss
  • Loading branch information
hocgin authored Nov 3, 2023
2 parents f50f556 + f862cb7 commit 670bead
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 65 deletions.
8 changes: 3 additions & 5 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineConfig } from 'dumi';
import { resolve } from 'path';

export const useLogger = () => {
let result: any = [];
let result = [];
let offLogger = process.env.USE_LOG !== 'true';
console.debug(`[${offLogger ? '禁用' : '启用'}]日志打印`);
if (offLogger) {
Expand All @@ -20,7 +20,7 @@ export default defineConfig({
themeConfig: {
name: 'HUI',
logo: 'https://cdn.hocgin.top/uPic/mp_logo.png',
footer: false
footer: false,
},
locales: [
{ id: 'zh-CN', name: '中文' },
Expand All @@ -31,9 +31,7 @@ export default defineConfig({
alias: {
'@': `${resolve(__dirname, 'src')}`,
},
extraBabelPlugins: [
...useLogger(),
],
extraBabelPlugins: [...useLogger()],
resolve: { entryFile: './src/index.tsx' },
ssr: process.env.NODE_ENV === 'development' ? false : {},
});
6 changes: 2 additions & 4 deletions .fatherrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IFatherConfig } from 'father/dist/types';
export const ANT_PREFIX_CLS = 'hui-';

export const useLogger = () => {
let result: any = [];
let result = [];
let offLogger = process.env.USE_LOG !== 'true';
console.debug(`[${offLogger ? '禁用' : '启用'}]日志打印`);
if (offLogger) {
Expand All @@ -25,7 +25,5 @@ export default defineConfig({
'@': resolve(__dirname, './src'),
'@@': resolve(__dirname, './src/.dumi/tmp'),
},
extraBabelPlugins: [
...useLogger(),
],
extraBabelPlugins: [...useLogger()],
} as IFatherConfig);
32 changes: 19 additions & 13 deletions src/Header/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import React, { useEffect, useState } from 'react';
import { configResponsive, useResponsive, useRequest } from 'ahooks';
import { useResponsive, useRequest } from 'ahooks';
import classnames from 'classnames';
import { MenuOutlined, CloseOutlined } from '@ant-design/icons';
import {
MenuOutlined,
CloseOutlined,
LoadingOutlined,
} from '@ant-design/icons';

import { ConfigContext } from '@/ConfigProvider';
import { Divider } from 'antd';
import { DoveService } from '@/Request';
import { PromiseKit } from '@hocgin/hkit';
import Promise from '../../../Promise';

configResponsive({
small: 0,
middle: 800,
large: 1200,
});

type Mode = 'none' | 'fixed' | 'sticky';

type Props = {
Expand All @@ -30,7 +28,7 @@ const HeaderMenu: React.FC<Props> = ({ menus, prefix, suffix, ...props }) => {
const responsive = useResponsive();
let [isOpenMenu, setIsOpenMenu] = useState(responsive?.middle);
let [user, setUser] = useState<any>(PromiseKit.CacheKit.getUser());
let { run } = useRequest(
let { run, loading } = useRequest(
async () => {
return await DoveService.getCurrentUser(false);
},
Expand Down Expand Up @@ -65,7 +63,9 @@ const HeaderMenu: React.FC<Props> = ({ menus, prefix, suffix, ...props }) => {
})}
>
{(menus || []).map(({ label }, index) => (
<li key={index}>{label}</li>
<li className={`${prefixCls}-navigation-item`} key={index}>
{label}
</li>
))}
</ul>
{prefix && <PrefixMenu prefixCls={prefixCls}>{prefix}</PrefixMenu>}
Expand All @@ -84,9 +84,15 @@ const HeaderMenu: React.FC<Props> = ({ menus, prefix, suffix, ...props }) => {
<>
<Divider type="vertical" />
{!user ? (
<a className={`${prefixCls}-login`} href="/login">
登陆
</a>
loading ? (
<>
<LoadingOutlined />
</>
) : (
<a className={`${prefixCls}-login`} href="/login">
登陆
</a>
)
) : (
<Promise.UserAvatar defaultParams={user} />
)}
Expand Down
12 changes: 4 additions & 8 deletions src/Header/demos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ import { Header, Notification } from '@hocgin/ui';

export default () => {
return (
<div style={{ backgroundColor: 'black', height: '500px' } as any}>
<div style={{ backgroundColor: 'black', height: '500px' }}>
<Header
style={{ padding: '0 10px 0' } as any}
style={{ padding: '0 10px 0' }}
mode={'sticky'}
logo={<Header.TextLogo title={'你好'} />}
prefix={
<>
<Notification.Indicator count={0} />
</>
}
prefix={<Notification.Indicator count={0} />}
// suffix={<><Notification.Indicator /></>}
menus={[
{ label: <a href={'www.baidu.com'}>🐰 标题</a> },
{ label: <a href={'www.baidu.com'}>🖍️ 标题</a> },
]}
logined
/>
<div style={{ height: 500 } as any}>4</div>
<div style={{ height: 500 }}>4</div>
</div>
);
};
71 changes: 36 additions & 35 deletions src/Header/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
@import '../../mixin.scss';

$header-prefix-cls: $hui-prefix + '-header';
$header-menu-prefix-cls: $hui-prefix + '-menu';

$largeHeaderHeight: var(--large-header-height, 70px);
$middleHeaderHeight: var(--small-header-height, 70px);
$header-menu-prefix-cls: $header-prefix-cls + '-menu';

.#{$header-prefix-cls} {
width: 100%;
height: $largeHeaderHeight;
height: var(--large-header-height, 70px);
z-index: 1000;
display: flex;
align-items: center;
Expand Down Expand Up @@ -90,6 +87,8 @@ $middleHeaderHeight: var(--small-header-height, 70px);
}

.#{$header-menu-prefix-cls} {
display: flex;

&-action {
display: flex;
align-items: center;
Expand All @@ -112,35 +111,36 @@ $middleHeaderHeight: var(--small-header-height, 70px);
list-style: none;
user-select: none;

a {
color: #111111;
text-decoration: none;
font-size: 16px;
//margin: 0 10px;
font-weight: 500;
display: inline-block;
padding: 2px 4px;
border-radius: 2px;

&:hover {
background-color: #11111108;
}

&:hover:before {
visibility: visible;
width: 100%;
}

&:before {
content: '';
position: absolute;
height: 3px;
width: 0;
bottom: 0;
left: 0;
visibility: hidden;
transition: all 0.3s ease-in-out 0s;
}
}

li a {
color: #111111;
text-decoration: none;
font-size: 16px;
//margin: 0 10px;
font-weight: 500;
display: inline-block;
padding: 2px 4px;
border-radius: 2px;

&:hover {
background-color: #11111108;
}

&:hover:before {
visibility: visible;
width: 100%;
}

&:before {
content: '';
position: absolute;
height: 3px;
width: 0;
bottom: 0;
left: 0;
visibility: hidden;
transition: all 0.3s ease-in-out 0s;
}
}

Expand Down Expand Up @@ -203,8 +203,9 @@ $middleHeaderHeight: var(--small-header-height, 70px);

@include mobile {
.#{$header-prefix-cls} {
height: $middleHeaderHeight;
height: var(--small-header-height, 70px);
}

.#{$header-menu-prefix-cls} {
&-navigation {
position: fixed;
Expand Down
1 change: 1 addition & 0 deletions typings/global/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
declare module '*.css';
declare module '*.less';
declare module '*.scss';
declare module '*.png';
declare module '*.jpg';
declare module '*.gif';
Expand Down

0 comments on commit 670bead

Please sign in to comment.