Skip to content

Commit

Permalink
Cleanup: move components out
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Apr 25, 2024
1 parent ef5f9bc commit 7ba7836
Show file tree
Hide file tree
Showing 6 changed files with 448 additions and 429 deletions.
31 changes: 31 additions & 0 deletions src/components/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Nebari Development Team.
// Distributed under the terms of the Modified BSD License.
import { TranslationBundle } from '@jupyterlab/translation';
import { classes, LabIcon } from '@jupyterlab/ui-components';
import * as React from 'react';
import { IItem } from '../types';

export function TypeCard(props: {
trans: TranslationBundle;
item: IItem;
}): React.ReactElement {
const { item } = props;
return (
<div
onClick={() => item.execute()}
className="jp-Launcher-TypeCard jp-LauncherCard"
title={item.caption}
tabIndex={0}
>
<div className="jp-LauncherCard-icon">
<LabIcon.resolveReact
icon={item.icon}
iconClass={classes(item.iconClass, 'jp-Icon-cover')}
/>
</div>
<div className="jp-LauncherCard-label">
<p>{item.label}</p>
</div>
</div>
);
}
43 changes: 43 additions & 0 deletions src/components/section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Nebari Development Team.
// Distributed under the terms of the Modified BSD License.
import { classes, LabIcon, caretRightIcon } from '@jupyterlab/ui-components';
import * as React from 'react';

export function CollapsibleSection(
props: React.PropsWithChildren<{
title: string;
className: string;
icon: LabIcon;
open: boolean;
}>
) {
const [open, setOpen] = React.useState<boolean>(props.open);

const handleToggle = (event: { currentTarget: { open: boolean } }) =>
setOpen(event.currentTarget.open);

return (
<details
onToggle={handleToggle}
className={classes(props.className, 'jp-CollapsibleSection')}
open={open}
>
<summary>
<div
className="jp-CollapsibleSection-CollapserIconWrapper"
aria-hidden="true"
>
<caretRightIcon.react className="jp-CollapsibleSection-CollapserIcon" />
</div>
<props.icon.react
tag="span"
className="jp-CollapsibleSection-CategoryIcon"
/>
<h3 className="jp-CollapsibleSection-Title">{props.title}</h3>
</summary>
<div className="jp-Launcher-CardGroup jp-Launcher-cardContainer">
{props.children}
</div>
</details>
);
}
Loading

0 comments on commit 7ba7836

Please sign in to comment.