Skip to content

Commit

Permalink
feat: mui tag
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyreilly committed Oct 7, 2024
1 parent 0a0e5a5 commit a3ab185
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion blog-website/blog/2024-03-20-text-first-mui-tabs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
slug: text-first-mui-tabs
title: 'Text-first MUI Tabs'
authors: johnnyreilly
tags: [react]
tags: [react, mui]
image: ./title-image.png
hide_table_of_contents: false
description: 'Learn how to use the MUI tabs component in a text first way that remains strongly typed.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
slug: mui-react-tree-view-check-children-uncheck-parents
title: 'MUI React Tree View: check children, uncheck parents'
authors: johnnyreilly
tags: [react]
tags: [react, mui]
image: ./title-image.png
hide_table_of_contents: false
description: 'Learn how to use the MUI treeview component with behaviour that selects child nodes when parents are select and deselects parent nodes when children are deselected.'
Expand Down Expand Up @@ -97,13 +97,13 @@ function getParentNode(
}

function getAllParentIds(items: TreeViewBaseItem[], id: string) {
const parentIds: string[] = [];
let parent = getParentNode(items, id);
while (parent) {
parentIds.push(parent.id);
parent = getParentNode(items, parent.id);
}
return parentIds;
const parentIds: string[] = [];
let parent = getParentNode(items, id);
while (parent) {
parentIds.push(parent.id);
parent = getParentNode(items, parent.id);
}
return parentIds;
}

function getSelectedIdsAndChildrenIds(
Expand Down Expand Up @@ -151,7 +151,7 @@ function determineIdsToSet(
const isDeselectingNode = currentIds.length > newIds.length;
if (isDeselectingNode) {
const removed = currentIds.filter((id) => !newIds.includes(id))[0];

const parentIdsToRemove = getAllParentIds(items, removed);

const childIdsToRemove = getSelectedIdsAndChildrenIds(items, [removed]);
Expand All @@ -168,9 +168,7 @@ function determineIdsToSet(
let parent = getParentNode(items, added);
while (parent) {
const childIds = parent.children?.map((node) => node.id) ?? [];
const allChildrenSelected = childIds.every((id) =>
idsToSet.includes(id),
);
const allChildrenSelected = childIds.every((id) => idsToSet.includes(id));
if (allChildrenSelected) {
idsToSet.push(parent.id);
parent = getParentNode(items, parent.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
slug: mui-react-tree-view-pass-data-to-treeitem
title: 'MUI React Tree View: pass data to TreeItem'
authors: johnnyreilly
tags: [react]
tags: [react, mui]
image: ./title-image.png
hide_table_of_contents: false
description: 'Learn how to pass arbitrary data to individual nodes in the MUI treeview component so individual nodes can be customised; for instance implementing a loader.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
slug: static-typing-for-mui-react-data-grid-columns
title: 'Static Typing for MUI React Data Grid Columns'
authors: johnnyreilly
tags: [typescript]
tags: [react, typescript, mui]
image: ./title-image.png
hide_table_of_contents: false
description: 'The MUI React Data Grid can be used with static typing to ensure the columns you pass to the component are correct. This post will show you how to do that.'
Expand Down
5 changes: 5 additions & 0 deletions blog-website/blog/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ jsdoc:
description: 'Type safety through JSDoc annotations.'
permalink: /jsdoc

mui:
label: 'MUI'
description: 'The MUI / Material UI component library.'
permalink: /mui

node.js:
label: 'Node.js'
description: 'The Node.js runtime.'
Expand Down

0 comments on commit a3ab185

Please sign in to comment.