Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7e96bcb

Browse files
committed
feat: added checkbox support.
1 parent 0944da2 commit 7e96bcb

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

‎src/block.tsx‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,37 @@ export const Block: React.FC<Block> = props => {
267267
const start = getListNumber(blockValue.id, blockMap);
268268

269269
return isTopLevel ? wrapList(output, start) : output;
270+
case "to_do":
271+
/**
272+
* There are only 3 possible cases when no nested to_dos:
273+
* 1. properties: {title: [["test"]], checked: [["No"]]}
274+
* 2. properties: {title: [["test"]], checked: [["Yes"]]}
275+
* 3. properties: {title: [["test"]]}
276+
*/
277+
const checkbox = block.value.properties;
278+
const { id } = block.value;
279+
280+
// remove other styles in to-do.
281+
const label: string = checkbox?.title
282+
.flat(1) // only flatten the first level
283+
.filter((ele: string | Array<string>) => typeof ele === "string")
284+
.join("");
285+
286+
const isChecked =
287+
checkbox?.checked && checkbox?.checked[0][0] === "Yes";
270288

289+
return (
290+
<div>
291+
<input
292+
className="notion-checkbox"
293+
type="checkbox"
294+
name=""
295+
id={id}
296+
checked={isChecked}
297+
/>
298+
<label htmlFor={id}>{label}</label>
299+
</div>
300+
);
271301
case "image":
272302
case "embed":
273303
case "figma":

‎src/styles.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ img.notion-page-icon {
313313
padding-left: 0px;
314314
}
315315

316+
.notion-checkbox {
317+
accent-color: #eb5757;
318+
}
319+
316320
.notion-asset-wrapper {
317321
margin: 0.5rem auto 0.5rem;
318322
max-width: 100%;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /