Skip to content

Commit ceae0ec

Browse files
committed
extract SlideCloseButton to its own component + CSS module
1 parent 0fde1db commit ceae0ec

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { MouseEventHandler } from 'react'
2+
import { useConfig } from '../hooks/useConfig.js'
3+
import { cn } from '../lib/utils.js'
4+
import styles from './SlideCloseButton.module.css'
5+
6+
export default function SlideCloseButton({ onClick }: { onClick: MouseEventHandler<HTMLButtonElement> | undefined }) {
7+
const { customClass } = useConfig()
8+
return (
9+
<button className={ cn( styles.slideCloseButton, customClass?.slideCloseButton ) } onClick={onClick}>&nbsp;</button>
10+
)
11+
}

src/components/viewers/CellPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DataFrame, stringify } from 'hightable'
22
import { useEffect, useState } from 'react'
3+
import SlideCloseButton from '../SlideCloseButton.js'
34
import ContentWrapper from './ContentWrapper.js'
45

56
interface ViewerProps {
@@ -49,7 +50,7 @@ export default function CellPanel({ df, row, col, setProgress, setError, onClose
4950
}, [df, col, row, setProgress, setError])
5051

5152
const headers = <>
52-
<button className="slideClose" onClick={onClose}>&nbsp;</button>
53+
<SlideCloseButton onClick={onClose} />
5354
<span>column `{df.header[col]}`</span>
5455
<span>row {row + 1}</span>
5556
</>

src/hooks/useConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface Config {
1616
imageView?: string
1717
markdownView?: string
1818
sideBar?: string
19+
slideCloseButton?: string
1920
spinner?: string
2021
textView?: string
2122
welcome?: string
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* slide panel close button */
2+
.slideClose,
3+
.slideClose:active,
4+
.slideClose:focus,
5+
.slideClose:hover {
6+
background: none;
7+
border: none;
8+
color: #888;
9+
font-size: 16px;
10+
height: 24px;
11+
margin-right: auto;
12+
outline: none;
13+
padding: 0;
14+
transition: color 0.3s;
15+
}
16+
.slideClose::before {
17+
content: "\27E9\27E9";
18+
}
19+
.slideClose:hover {
20+
color: #000;
21+
}

src/styles/app.css

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -299,25 +299,3 @@ input.search:focus {
299299
.resizer:hover {
300300
background-color: #9f9999;
301301
}
302-
303-
/* slide panel close button */
304-
.slideClose,
305-
.slideClose:active,
306-
.slideClose:focus,
307-
.slideClose:hover {
308-
background: none;
309-
border: none;
310-
color: #888;
311-
font-size: 16px;
312-
height: 24px;
313-
margin-right: auto;
314-
outline: none;
315-
padding: 0;
316-
transition: color 0.3s;
317-
}
318-
.slideClose::before {
319-
content: "\27E9\27E9";
320-
}
321-
.slideClose:hover {
322-
color: #000;
323-
}

0 commit comments

Comments
 (0)