Skip to content

Commit b3a607b

Browse files
ethansharM-i-k-e-l
andauthored
Docs UX fixes (#3673)
* Enhance code documentation and UI: add auto-collapse to sidebar, replace CodeIcon with image, and improve button styles * bump uilib-docs version --------- Co-authored-by: Miki Leib <[email protected]>
1 parent 7593949 commit b3a607b

File tree

8 files changed

+36
-24
lines changed

8 files changed

+36
-24
lines changed

docuilib/docusaurus.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ const darkCodeTheme = themes.dracula;
128128
},
129129
colorMode: {
130130
disableSwitch: true
131+
},
132+
docs: {
133+
sidebar: {
134+
autoCollapseCategories: true
135+
}
131136
}
132137
})
133138
}

docuilib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uilib-docs",
3-
"version": "3.21.0",
3+
"version": "3.22.0",
44
"main": "./src/index.ts",
55
"scripts": {
66
"docusaurus": "docusaurus",

docuilib/src/assets/icons/code.png

634 Bytes
Loading

docuilib/src/assets/icons/code.tsx

Lines changed: 0 additions & 11 deletions
This file was deleted.

docuilib/src/components/CodeBlock.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const CodeBlock: React.FC<CodeBlockProps> = ({
2121

2222
const containerStyle = useMemo<ComponentProps<'div'>['style']>(() => {
2323
return {
24-
fontSize,
25-
maxWidth: printWidth * fontSize
24+
fontSize
25+
// maxWidth: printWidth * fontSize
2626
};
2727
}, [fontSize, printWidth]);
2828

@@ -31,7 +31,7 @@ const CodeBlock: React.FC<CodeBlockProps> = ({
3131
<ThemeCodeBlock
3232
className={styles.codeBlock}
3333
language={language ?? 'jsx'}
34-
showLineNumbers={showLineNumbers ?? true}
34+
showLineNumbers={showLineNumbers}
3535
{...others}
3636
>
3737
{code}

docuilib/src/components/pageComponents/ContentItem.module.scss

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
.showCodeButton {
22
position: absolute;
3-
border: 0;
3+
border: 1px solid #ddd;
4+
border-radius: 4px;
5+
padding: 4px;
46
background: none;
5-
color: rgb(56, 153, 236);
67
cursor: pointer;
78
display: flex;
89
align-items: center;
9-
right: 0px;
10-
top: 0px;
10+
right: 4px;
11+
top: 4px;
12+
13+
&:hover {
14+
background: #eee;
15+
}
16+
17+
img {
18+
filter: grayscale(100%);
19+
opacity: 0.8;
20+
}
1121
}
1222

1323
.blocker {

docuilib/src/components/pageComponents/ContentItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {LiveProvider, LivePreview} from 'react-live';
44
import styles from './ContentItem.module.scss';
55
import ReactLiveScope from '../../theme/ReactLiveScope';
66
import CodeBlock from '../CodeBlock';
7-
import CodeIcon from '../../assets/icons/code';
87
import {isComponentSupported} from '../../utils/componentUtils';
8+
const showCodeIcon = require('../../assets/icons/code.png');
99

1010
type ComponentItemProps = {
1111
componentName: string;
@@ -71,8 +71,8 @@ const ComponentItem = (props: ComponentItemProps) => {
7171
{content}
7272
{showCodeButton && (
7373
<button onClick={toggleCode} className={styles.showCodeButton}>
74-
<CodeIcon/>
75-
{showCode ? 'Hide' : 'Show'} code
74+
<img src={showCodeIcon} width={20}/>
75+
{/* {showCode ? 'Hide' : 'Show'} code */}
7676
</button>
7777
)}
7878
</div>

docuilib/src/css/custom.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ html[data-theme='dark'] .docusaurus-highlight-code-line {
3333
background-color: rgba(0, 0, 0, 0.3);
3434
}
3535

36+
/* Markdown pages */
37+
38+
.container {
39+
padding: 0 48px;
40+
}
41+
3642
/** Docusaurus Navbar */
3743

3844
.navbar {
@@ -58,7 +64,7 @@ html[data-theme='dark'] .docusaurus-highlight-code-line {
5864
letter-spacing: 0.3px;
5965
line-height: 38px;
6066
border-bottom: 2px solid transparent;
61-
transition: all 0.2s ease-out;
67+
transition: all 0.18s ease-out;
6268
}
6369
.navbar__link--active {
6470
font-weight: 700;
@@ -207,8 +213,10 @@ html[data-theme='dark'] .docusaurus-highlight-code-line {
207213
border-bottom: 2px solid #F0F2F5;
208214
}
209215
.single-tab {
210-
font-size: 20px;
216+
font-size: 18px;
217+
font-weight: 500;
211218
color: #6E7881;
219+
border-bottom-width: 2px;
212220
}
213221
.single-tab[aria-selected='true'] {
214222
border-bottom-color: #20303C;

0 commit comments

Comments
 (0)