Skip to content

Commit

Permalink
✨ feat: Add global styles for font, colors, and scrollbar customization
Browse files Browse the repository at this point in the history
- Remove "GlobalStyle.ts" file
- Add "antdOverride.ts", "global.ts", and "index.ts" files
- "antdOverride.ts" contains overrides for Ant Design components
- "global.ts" contains global CSS styles for font, colors, and scrollbar
- "index.ts" exports the combined styles from "antdOverride.ts" and "global.ts" as a global style component.
  • Loading branch information
倏昱 committed Jul 18, 2023
1 parent a2c90c1 commit 01f735e
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 124 deletions.
124 changes: 0 additions & 124 deletions src/ThemeProvider/GlobalStyle.ts

This file was deleted.

24 changes: 24 additions & 0 deletions src/ThemeProvider/GlobalStyle/antdOverride.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Theme, css } from 'antd-style';

export default (token: Theme) => css`
.ant-tooltip-inner {
display: flex;
align-items: center;
justify-content: center;
min-height: unset;
padding: 4px 8px;
color: ${token.colorBgLayout};
background-color: ${token.colorText};
border-radius: ${token.borderRadiusSM}px;
}
.ant-tooltip-arrow {
&::before,
&::after {
background: ${token.colorText};
}
}
`;
101 changes: 101 additions & 0 deletions src/ThemeProvider/GlobalStyle/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { Theme, css } from 'antd-style';

export default (token: Theme) => css`
html,
body {
--font-settings: 'cv01', 'tnum', 'kern';
--font-variations: 'opsz' auto, tabular-nums;
overflow-x: hidden;
overflow-y: auto;
margin: 0;
padding: 0;
font-family: ${token.fontFamily};
font-size: ${token.fontSize}px;
font-feature-settings: var(--font-settings);
font-variation-settings: var(--font-variations);
line-height: 1;
color: ${token.colorTextBase};
text-size-adjust: none;
text-rendering: optimizelegibility;
vertical-align: baseline;
color-scheme: dark;
background-color: ${token.colorBgLayout};
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-overflow-scrolling: touch;
-webkit-tap-highlight-color: transparent;
}
body {
overflow-x: hidden;
height: 100vh;
}
#root {
min-height: 100vh;
}
code {
font-family: ${token.fontFamilyCode} !important;
span {
font-family: ${token.fontFamilyCode} !important;
}
}
p {
text-align: justify;
word-wrap: break-word;
}
::selection {
color: #000;
background: ${token.yellow9};
-webkit-text-fill-color: unset !important;
}
* {
box-sizing: border-box;
vertical-align: baseline;
}
@media only screen and (min-width: 574px) {
* {
::-webkit-scrollbar {
cursor: pointer;
width: 4px;
height: 4px;
background-color: transparent;
}
::-webkit-scrollbar-thumb {
cursor: pointer;
background-color: transparent;
border-radius: 2px;
transition: background-color 500ms ${token.motionEaseOut};
&:hover {
background-color: ${token.colorText};
}
}
::-webkit-scrollbar-corner {
display: none;
width: 0;
height: 0;
}
&:hover {
::-webkit-scrollbar-thumb {
background-color: ${token.colorFill};
}
}
}
}
`;
8 changes: 8 additions & 0 deletions src/ThemeProvider/GlobalStyle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createGlobalStyle } from 'antd-style';

import antdOverride from './antdOverride';
import global from './global';

const GlobalStyle = createGlobalStyle(({ theme }) => [global(theme), antdOverride(theme)]);

export default GlobalStyle;

1 comment on commit 01f735e

@vercel
Copy link

@vercel vercel bot commented on 01f735e Jul 18, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

lobe-ui – ./

lobe-ui.vercel.app
lobe-ui-git-master-lobehub.vercel.app
lobe-ui-lobehub.vercel.app
ui.lobehub.com

Please sign in to comment.