Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc/0.6.0 #69

Merged
merged 5 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rdpc-ui",
"version": "0.5.0",
"version": "0.6.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
Binary file modified public/assets/galaxy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,14 @@
*/
'use client';

import { useTheme } from '@/lib/emotion';
import { Table, Typography, css } from '@icgc-argo/uikit';
import { columns } from '../tableConfig';

export type ProgramsData = {
shortName: string;
name: string | null;
cancerTypes: Array<string>;
countries: Array<string> | null;
membershipType: ArgoMembershipKey;
genomicDonors: number | null;
submittedDonors: number;
commitmentDonors: number;
administrators: { firstName: string; lastName: string; email: string }[];
donorPercentage: number;
};
import { css } from '@/lib/emotion';
import { Table, Typography } from '@icgc-argo/uikit';
import { columns } from '../program-table/config';

export type ProgramData = any;
export type ArgoMembershipKey = 'FULL' | 'ASSOCIATE';

export default function ProgramList({ programs }: { programs: ProgramsData[] }) {
const theme = useTheme();
export default function ProgramList({ programs }: { programs: ProgramData[] }) {
const programsArraySize = programs.length;

return (
Expand All @@ -49,8 +36,9 @@ export default function ProgramList({ programs }: { programs: ProgramsData[] })
>
<Typography
variant="label"
color="grey"
component="div"
css={css`
color: ${theme.colors.grey};
min-height: 32px;
display: flex;
align-items: center;
Expand All @@ -62,6 +50,7 @@ export default function ProgramList({ programs }: { programs: ProgramsData[] })
<Table
data={programs}
columns={columns}
pageCount={20}
withSideBorders
withRowBorder
withStripes
Expand Down
75 changes: 75 additions & 0 deletions src/app/(post-login)/submission/components/ProgramMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2023 The Ontario Institute for Cancer Research. All rights reserved
*
* This program and the accompanying materials are made available under the terms of
* the GNU Affero General Public License v3.0. You should have received a copy of the
* GNU Affero General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
'use client';

import { css } from '@/lib/emotion';
import { MenuItem } from '@icgc-argo/uikit';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { MouseEventHandler, useState } from 'react';

export default function ProgramMenu({
programs,
searchQuery,
}: {
programs: { shortName: string }[];
searchQuery: string;
}) {
const pathname = usePathname();
const [activeProgramIndex, setActiveProgramIndex] = useState(-1);

const filteredPrograms = !searchQuery.length
? programs
: programs.filter(({ shortName }) => shortName.search(new RegExp(searchQuery, 'i')) > -1);

const setActiveProgram =
(index: number): MouseEventHandler =>
() =>
setActiveProgramIndex(index);

return (
<>
<Link
href="/submission"
css={css`
text-decoration: none !important;
`}
>
<MenuItem
level={2}
content="All Programs"
onClick={setActiveProgram(-1)}
selected={pathname === '/submission'}
/>
</Link>

{filteredPrograms.map((program, programIndex) => (
<MenuItem
level={2}
key={program.shortName}
content={program.shortName}
onClick={setActiveProgram(programIndex)}
selected={programIndex === activeProgramIndex}
>
<MenuItem level={3}>{program.shortName}</MenuItem>
</MenuItem>
))}
</>
);
}
50 changes: 50 additions & 0 deletions src/app/(post-login)/submission/components/Search.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2023 The Ontario Institute for Cancer Research. All rights reserved
*
* This program and the accompanying materials are made available under the terms of
* the GNU Affero General Public License v3.0. You should have received a copy of the
* GNU Affero General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
'use client';

import { Input, MenuItem, css } from '@icgc-argo/uikit';

export default function Search({
query,
onChange,
}: {
query: string;
onChange: (s: string) => void;
}) {
return (
<MenuItem
level={1}
selected
contentAs="div"
content={
<Input
aria-label="programs search"
onChange={(event) => {
onChange(event.target.value);
}}
value={query}
css={css`
flex: 1;
`}
preset="search"
/>
}
/>
);
}
39 changes: 39 additions & 0 deletions src/app/(post-login)/submission/components/SideMenu/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2023 The Ontario Institute for Cancer Research. All rights reserved
*
* This program and the accompanying materials are made available under the terms of
* the GNU Affero General Public License v3.0. You should have received a copy of the
* GNU Affero General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
'use client';

import { Icon, MenuItem, SubMenu } from '@icgc-argo/uikit';
import { useState } from 'react';
import ProgramMenu from '../ProgramMenu';
import Search from '../Search';

const SideMenuContent = ({ content }: { content: any[] }) => {
const [programNameSearch, setProgramNameSearch] = useState('');

return (
<SubMenu>
<MenuItem icon={<Icon name="programs" />} content={'My Programs'} selected>
<Search query={programNameSearch} onChange={setProgramNameSearch} />
<ProgramMenu programs={content.slice(0, -1)} searchQuery={programNameSearch} />
</MenuItem>
</SubMenu>
);
};

export default SideMenuContent;
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,35 @@
'use client';

import { css, useTheme } from '@/lib/emotion';
import { ReactNode } from 'react';
import SideMenu from './components/Sidemenu';
import TitleBar from './components/TitleBar';
import SideMenuContent from './Content';
import SideMenuToggle, { TOGGLE_HEIGHT_PX } from './Toggle';
import { SideMenuProps } from './types';

export default function SubmissionLayout({ children }: { children: ReactNode }) {
const SideMenu = ({ content, onToggle, isActive }: SideMenuProps) => {
const theme = useTheme();

return (
<div
css={css`
display: grid;
grid-template-columns: 248px 1fr;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
background-color: ${theme.colors.white};
`}
>
<SideMenu />
<div>
<TitleBar />
<div
id="content"
css={css`
background: ${theme.colors.grey_4};
padding: 40px;
height: 100%;

> div {
background: white;
}
`}
>
{children}
</div>
<div
css={css`
height: calc(100vh - ${TOGGLE_HEIGHT_PX}px);
overflow-y: auto;
visibility: ${isActive ? 'visible' : 'hidden'};
`}
>
<SideMenuContent content={content} />
</div>
<SideMenuToggle onToggle={onToggle} open={isActive} />
</div>
);
}
};

export default SideMenu;
55 changes: 55 additions & 0 deletions src/app/(post-login)/submission/components/SideMenu/Toggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Interpolation, Theme, css } from '@emotion/react';
import { Icon, UikitIconNames } from '@icgc-argo/uikit';

const ToggleChevron = ({ css, name }: { css?: Interpolation<Theme>; name: UikitIconNames }) => (
<Icon height="10px" fill="primary_2" css={css} name={name} />
);

export const TOGGLE_HEIGHT_PX = 56;
const SideMenuToggle = ({ onToggle, open }: { onToggle: () => void; open: boolean }) => (
<div
css={css`
height: ${TOGGLE_HEIGHT_PX}px;
width: 100%;
display: flex;
justify-content: flex-end;
padding-right: ${open ? '22px' : '12px'};

&:hover {
cursor: pointer;
}
`}
onClick={onToggle}
>
<div
css={css`
display: ${open ? 'block' : 'none'};
`}
>
<ToggleChevron name="chevron_left" />
<ToggleChevron
name="chevron_left"
css={css`
position: relative;
left: -3px;
`}
/>
</div>
<div
css={css`
display: ${!open ? 'block' : 'none'};
`}
>
<ToggleChevron name="chevron_right" />
<ToggleChevron
name="chevron_right"
css={css`
position: relative;
left: -3px;
`}
/>
</div>
</div>
);

export default SideMenuToggle;
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
'use client';

export default function SideMenu() {
return <div>SideMenu</div>;
}
export type SideMenuProps = { content: any; onToggle: () => void; isActive: boolean };
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
*/
'use client';

import { css } from '@/lib/emotion';
import { css, useTheme } from '@/lib/emotion';
import { TitleBar as TitleBarComp } from '@icgc-argo/uikit';

export default function TitleBar() {
const TitleBar = () => {
const theme = useTheme();
return (
<div
css={css`
display: flex;
padding: 0 20px;
background-color: ${theme.colors.white};
`}
>
<TitleBarComp
Expand Down Expand Up @@ -56,4 +58,6 @@ export default function TitleBar() {
</div>
</div>
);
}
};

export default TitleBar;
Loading