-
Notifications
You must be signed in to change notification settings - Fork 14
[OGUI-1805] Component library and layout #3187
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
base: dev
Are you sure you want to change the base?
Changes from 45 commits
696d56a
1a45249
38f90ed
6b93174
6faffd1
8231106
3374b5b
8643941
f0700da
5311ebf
494c626
5232c19
ef7ecfb
7ae3345
b75be95
8fe9693
c2f5922
05f7465
7505c32
d473dcf
4de90cd
a2a4648
2d69a8d
7376100
71129cc
15bf271
e7cfafa
948a4a0
0114076
17480d5
2b36cbf
68c0c6e
0c55740
7e5f624
9868edb
f903496
cea8809
f1f04e2
a256e5c
2a85fbf
87a4785
d011b9d
6b0e0c1
c227714
1c064e1
aed683b
f379bc7
d2c7fb9
fd632e9
0ac6bfe
8f2ef4d
28e3c11
7c3798b
6c28e1f
1398a2d
b35948c
a789807
767cdbd
584461c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { Link } from 'react-router'; | ||
| import { IconArrowCircleRight, IconContainer, IconExpandRight } from '~/ui/icon'; | ||
|
|
||
| interface BoxInterface { | ||
| children: React.ReactNode; | ||
| link: string | null; | ||
| } | ||
|
|
||
| interface PrimaryBoxInterface extends BoxInterface { | ||
| className_div1: string; | ||
| className_div2: string; | ||
| } | ||
|
|
||
| export const Box = ({ children, link, className_div1, className_div2 }: PrimaryBoxInterface) => ( | ||
| <div className={`bg-gray m3 ${className_div1}`}> | ||
| {link && <div className={`flex-row justify-center ${className_div2}`}> | ||
| <div className="w-90 flex-row justify-end"> | ||
|
Check failure on line 32 in Tokenization/webapp/app/components/box.tsx
|
||
| <Link to={link}> | ||
|
Check failure on line 33 in Tokenization/webapp/app/components/box.tsx
|
||
| <IconContainer className="scale15 actionable-icon"> | ||
|
Check failure on line 34 in Tokenization/webapp/app/components/box.tsx
|
||
| <IconExpandRight /> | ||
|
Check failure on line 35 in Tokenization/webapp/app/components/box.tsx
|
||
| </IconContainer> | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| } | ||
| {children} | ||
| </div> | ||
| ); | ||
|
|
||
| export const Box1_2 = ({ children, link }: BoxInterface) => ( | ||
| <Box | ||
| link={link} | ||
| className_div1="min-height-box-1" | ||
| className_div2="mv3" | ||
| > | ||
| <div className="flex-row justify-center"> | ||
| <div className="w-95"> | ||
| {children} | ||
| </div> | ||
| </div> | ||
| </Box> | ||
| ); | ||
|
|
||
| export const Box1_1 = ({ children, link }: BoxInterface) => ( | ||
| <Box | ||
| link={link} | ||
| className_div1="min-height-box-1" | ||
| className_div2="mv4" | ||
| > | ||
| <div className='p4'> | ||
| <div className='mv2'></div> | ||
| {children} | ||
| </div> | ||
| </Box> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import type { ButtonInterface } from "../window/window" | ||
|
|
||
| const FormButton = ({type, action, className, children}: ButtonInterface) => { | ||
| const onClick =(e: React.MouseEvent<HTMLButtonElement>) => { | ||
| e.preventDefault(); | ||
| action?.(); | ||
| } | ||
|
|
||
| return <button | ||
| type={type} | ||
| className={`btn ${className}`} | ||
| onClick={onClick} | ||
| > | ||
| {children} | ||
| </button> | ||
| } | ||
|
|
||
| export const SubmitButton = ({action, className}: ButtonInterface) => { | ||
| return <FormButton | ||
| className={`btn-primary ${className}`} | ||
| type='submit' | ||
| action={action} | ||
| > | ||
| Submit | ||
| </FormButton> | ||
| } | ||
|
|
||
| export const ResetButton = ({action, className}: ButtonInterface) => { | ||
| return <FormButton | ||
| className={`btn-danger ${className}`} | ||
| type='button' | ||
| action={action} | ||
| > | ||
| Reset | ||
| </FormButton> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { type FormInputInterface } from './form.d'; | ||
|
|
||
| export const FormInput = <T extends string | number = string>({ | ||
| value, | ||
| setValue, | ||
| labelText, | ||
| containerProps, | ||
| labelProps, | ||
| inputProps, | ||
| }: FormInputInterface<T>) => { | ||
| const inputId = inputProps?.id ?? labelProps?.htmlFor ?? undefined; | ||
|
|
||
| const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
| const { target } = e; | ||
| let newVal: T; | ||
| if (typeof value === 'number') { | ||
| const parsed = parseFloat(target.value); | ||
| newVal = (isNaN(parsed) ? 0 : parsed) as T; | ||
| } else { | ||
| newVal = target.value as T; | ||
| } | ||
| setValue(newVal); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className='my-input' {...containerProps}> | ||
| {labelText && ( | ||
| <label {...labelProps} htmlFor={inputId}> | ||
| {labelText} | ||
| </label> | ||
| )} | ||
| <input | ||
| {...inputProps} | ||
| id={inputId} | ||
| value={value as unknown as string} | ||
| onChange={handleChange} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
| import { type SelectInterface } from './form.d'; | ||
| import { FormSelectBase, SelectFrame, SelectFrameMulti } from './select-helper'; | ||
|
|
||
| export const FormSelect = <T extends string | number = string, >(props: SelectInterface<T>) => { | ||
| const { value, setValue, options } = { ...props }; | ||
| const selected = options.find((o) => o.value === value) ?? null; | ||
| const handleSelect = (val: T) => { | ||
| setValue(val); | ||
| }; | ||
|
|
||
| return ( | ||
| <FormSelectBase | ||
| {...props} | ||
| selected={selected} | ||
| handleSelect={handleSelect as (value: T extends Array<infer U> ? U : T) => void} | ||
| render={SelectFrame} | ||
| /> | ||
|
|
||
| ); | ||
| }; | ||
|
|
||
| export const FormSelectMulti = <T extends string | number = string, >(props: SelectInterface<T[]>)=> { | ||
| const { value, setValue, options } = { ...props }; | ||
| const selected = options.filter((o) => value.includes(o.value as unknown as T)) || []; | ||
|
|
||
| const handleSelect = (val: T) => { | ||
| setValue((prev) => [...prev, val]); | ||
| }; | ||
|
|
||
| const handleDeselect = (val: T) => { | ||
| setValue((prev) => prev.filter(v => v !== val)); | ||
| }; | ||
|
|
||
| return ( | ||
| <FormSelectBase | ||
| {...props} | ||
| selected={selected} | ||
| handleSelect={handleSelect} | ||
| handleDeselect={handleDeselect} | ||
| takeSelectedToOption={false} | ||
| render={SelectFrameMulti} | ||
| /> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import type React from 'react'; | ||
| import { type SetStateAction } from 'react'; | ||
| import type { OptionType as Option, DialogPropsBase as DPB } from '../../utils/types'; | ||
|
|
||
| export interface FormInputInterface<T extends string | number = string> { | ||
| value: T; | ||
| setValue: React.Dispatch<React.SetStateAction<T>>; | ||
| labelText?: string; | ||
| containerProps?: React.HTMLAttributes<HTMLDivElement>; | ||
| labelProps?: React.LabelHTMLAttributes<HTMLLabelElement>; | ||
| inputProps?: React.InputHTMLAttributes<HTMLInputElement>; | ||
| } | ||
|
|
||
| export interface SelectInterface<T = string | number | (string | number)[], V = T extends Array<infer U> ? U : T> { | ||
| id: string; | ||
| options: Option[]; | ||
| placeholder?: string; | ||
| label: string | null; | ||
| value: T; | ||
| setValue: React.Dispatch<SetStateAction<T>>; | ||
| selected?: Option | Option[] | null; | ||
| handleSelect?: (value: V) => void; | ||
| handleDeselect?: (value: V) => void; | ||
| takeSelectedToOption?: boolean; | ||
| render?: React.ElementType; | ||
| } | ||
|
|
||
| export interface SelectLabelProps<T extends string | number> extends DPB { | ||
| selected: Option | Option[] | null; | ||
| placeholder: string; | ||
| handleDeselect?: (value: T) => void; | ||
| } | ||
|
|
||
| export interface SelectOptionsProps<T extends string | number> extends DPB { | ||
| options: Option[]; | ||
| selected?: Option | Option[] | null; | ||
| takeSelectedToOption?: boolean; | ||
| handleSelect?: (value: T) => void; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
| * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
| * All rights not expressly granted are reserved. | ||
| * | ||
| * This software is distributed under the terms of the GNU General Public | ||
| * License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
| * | ||
| * In applying this license CERN does not waive the privileges and immunities | ||
| * granted to it by virtue of its status as an Intergovernmental Organization | ||
| * or submit itself to any jurisdiction. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| interface FormInterface extends React.HTMLAttributes<HTMLFormElement> {} | ||
|
|
||
| export const Form = ({ children, className, id }: FormInterface) => { | ||
| const _className = className ?? ''; | ||
|
|
||
| return ( | ||
| <div | ||
| id={id} | ||
| className={_className} | ||
| > | ||
| <form> | ||
| {children} | ||
| </form> | ||
| </div> | ||
| ); | ||
| }; |
Uh oh!
There was an error while loading. Please reload this page.