Skip to content

Commit

Permalink
Merge pull request binary-com#11 from sandeep-deriv/sandeep/73382/dbo…
Browse files Browse the repository at this point in the history
…t-add-charts

Sandeep/73382/dbot add charts
  • Loading branch information
rupato-deriv committed Sep 12, 2022
2 parents ea84ee4 + 53b095b commit 11f2572
Show file tree
Hide file tree
Showing 14 changed files with 323 additions and 75,845 deletions.
25,598 changes: 0 additions & 25,598 deletions packages/bot-web-ui/package-lock.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { Button, Popover } from '@deriv/components';

type TToolbarButton = {
popover_message?: string;
button_id: string;
button_classname: string;
buttonOnClick: () => void;
icon: React.ReactElement;
button_text: string;
};

const ToolbarButton = ({
popover_message,
button_id,
button_classname,
buttonOnClick,
icon,
button_text,
}: TToolbarButton) => (
<Popover alignment='bottom' message={popover_message} should_disable_pointer_events>
<Button id={button_id} className={button_classname} has_effect onClick={buttonOnClick} icon={icon} green>
{button_text}
</Button>
</Popover>
);

export default ToolbarButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { popover_zindex } from 'Constants/z-indexes';
import { Icon, Popover } from '@deriv/components';

type TToolbarIcon = {
popover_message: string;
icon: string;
icon_id: string;
iconOnClick: () => void;
icon_color?: string;
};

const ToolbarIcon = ({ popover_message, icon, icon_id, icon_color, iconOnClick }: TToolbarIcon) => (
<Popover alignment='bottom' message={popover_message} zIndex={popover_zindex.TOOLBAR} should_disable_pointer_events>
<Icon
icon={icon}
id={icon_id}
className='toolbar__icon'
onClick={iconOnClick}
{...(icon_color ? { color: icon_color } : null)}
/>
</Popover>
);

export default ToolbarIcon;
Original file line number Diff line number Diff line change
@@ -1,132 +1,13 @@
import { Button, Icon, Popover, Dialog } from '@deriv/components';
import { Localize, localize } from '@deriv/translations';
import React from 'react';
import { Icon, Dialog } from '@deriv/components';
import { Localize, localize } from '@deriv/translations';
import LoadModal from 'Components/load-modal';
import SaveModal from 'Components/save-modal';
import { tabs_title } from 'Constants/bot-contents';
import { popover_zindex } from 'Constants/z-indexes';
import { connect } from 'Stores/connect';
import RootStore from 'Stores/index';

type TIconButton = {
popover_message: string;
icon: string;
icon_id: string;
iconOnClick: () => void;
icon_color?: string;
};

const IconButton = ({ popover_message, icon, icon_id, icon_color, iconOnClick }: TIconButton) => (
<Popover alignment='bottom' message={popover_message} zIndex={popover_zindex.TOOLBAR} should_disable_pointer_events>
<Icon
icon={icon}
id={icon_id}
className='toolbar__icon'
onClick={iconOnClick}
{...(icon_color ? { color: icon_color } : null)}
/>
</Popover>
);

type TToolbarButton = {
popover_message?: string;
button_id: string;
button_classname: string;
buttonOnClick: () => void;
icon: React.ReactElement;
button_text: string;
};

const ToolbarButton = ({
popover_message,
button_id,
button_classname,
buttonOnClick,
icon,
button_text,
}: TToolbarButton) => (
<Popover alignment='bottom' message={popover_message} should_disable_pointer_events>
<Button id={button_id} className={button_classname} has_effect onClick={buttonOnClick} icon={icon} green>
{button_text}
</Button>
</Popover>
);

type TWorkspaceGroup = {
has_redo_stack: boolean;
has_undo_stack: boolean;
onResetClick: () => void;
onSortClick: () => void;
onUndoClick: (param?: boolean) => void;
onZoomInOutClick: (param?: boolean) => void;
toggleLoadModal: () => void;
toggleSaveModal: () => void;
};

const WorkspaceGroup = ({
has_redo_stack,
has_undo_stack,
onResetClick,
onSortClick,
onUndoClick,
onZoomInOutClick,
toggleLoadModal,
toggleSaveModal,
}: TWorkspaceGroup) => (
<div className='toolbar__group toolbar__group-btn'>
<IconButton
popover_message={localize('Reset')}
icon='IcReset'
icon_id='db-toolbar__reset-button'
iconOnClick={onResetClick}
/>
<IconButton
popover_message={localize('Import')}
icon='IcFolderOpen'
icon_id='db-toolbar__import-button'
iconOnClick={toggleLoadModal}
/>
<IconButton
popover_message={localize('Save')}
icon='IcSave'
icon_id='db-toolbar__save-button'
iconOnClick={toggleSaveModal}
/>
<div className='vertical-divider' />
<IconButton
popover_message={localize('Undo')}
icon='IcUndo'
icon_id='db-toolbar__undo-button'
icon_color={has_undo_stack ? undefined : 'disabled'}
iconOnClick={() => onUndoClick(/* redo */ false)}
/>
<IconButton
popover_message={localize('Redo')}
icon='IcRedo'
icon_id='db-toolbar__redo-button'
icon_color={has_redo_stack ? undefined : 'disabled'}
iconOnClick={() => onUndoClick(/* redo */ true)}
/>
<IconButton
popover_message={localize('Sort')}
icon='IcSort'
icon_id='db-toolbar__sort-button'
iconOnClick={onSortClick}
/>
<IconButton
popover_message={localize('Zoom in')}
icon='IcZoomIn'
icon_id='db-toolbar__zoom-in-button'
iconOnClick={() => onZoomInOutClick(/* in */ true)}
/>
<IconButton
popover_message={localize('Zoom out')}
icon='IcZoomOut'
icon_id='db-toolbar__zoom-out'
iconOnClick={() => onZoomInOutClick(/* in */ false)}
/>
</div>
);
import ToolbarButton from './toolbar-button';
import WorkspaceGroup from './workspace-group';

type TToolbar = {
active_tab: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import React from 'react';
import { localize } from '@deriv/translations';
import ToolbarIcon from './toolbar-icon';

type TWorkspaceGroup = {
has_redo_stack: boolean;
has_undo_stack: boolean;
onResetClick: () => void;
onSortClick: () => void;
onUndoClick: (param?: boolean) => void;
onZoomInOutClick: (param?: boolean) => void;
toggleLoadModal: () => void;
toggleSaveModal: () => void;
};

const WorkspaceGroup = ({
has_redo_stack,
has_undo_stack,
onResetClick,
onSortClick,
onUndoClick,
onZoomInOutClick,
toggleLoadModal,
toggleSaveModal,
}: TWorkspaceGroup) => (
<div className='toolbar__group toolbar__group-btn'>
<ToolbarIcon
popover_message={localize('Reset')}
icon='IcReset'
icon_id='db-toolbar__reset-button'
iconOnClick={onResetClick}
/>
<ToolbarIcon
popover_message={localize('Import')}
icon='IcFolderOpen'
icon_id='db-toolbar__import-button'
iconOnClick={toggleLoadModal}
/>
<ToolbarIcon
popover_message={localize('Save')}
icon='IcSave'
icon_id='db-toolbar__save-button'
iconOnClick={toggleSaveModal}
/>
<div className='vertical-divider' />
<ToolbarIcon
popover_message={localize('Undo')}
icon='IcUndo'
icon_id='db-toolbar__undo-button'
icon_color={has_undo_stack ? undefined : 'disabled'}
iconOnClick={() => onUndoClick(/* redo */ false)}
/>
<ToolbarIcon
popover_message={localize('Redo')}
icon='IcRedo'
icon_id='db-toolbar__redo-button'
icon_color={has_redo_stack ? undefined : 'disabled'}
iconOnClick={() => onUndoClick(/* redo */ true)}
/>
<ToolbarIcon
popover_message={localize('Sort')}
icon='IcSort'
icon_id='db-toolbar__sort-button'
iconOnClick={onSortClick}
/>
<ToolbarIcon
popover_message={localize('Zoom in')}
icon='IcZoomIn'
icon_id='db-toolbar__zoom-in-button'
iconOnClick={() => onZoomInOutClick(/* in */ true)}
/>
<ToolbarIcon
popover_message={localize('Zoom out')}
icon='IcZoomOut'
icon_id='db-toolbar__zoom-out'
iconOnClick={() => onZoomInOutClick(/* in */ false)}
/>
</div>
);

export default WorkspaceGroup;
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';
import { Field as FormField, Formik, Form, FieldProps } from 'formik';
import { Input, Icon } from '@deriv/components';
import { localize } from '@deriv/translations';

type TSearchBox = {
is_search_loading: boolean;
onSearch: () => void;
onSearchBlur: () => void;
onSearchClear: (
param: (field: string, value: number | string, shouldValidate?: boolean | undefined) => void
) => void;
onSearchKeyUp: (param: () => void) => void;
};

type TFormValues = { [key: string]: string };

const SearchBox = ({ is_search_loading, onSearch, onSearchBlur, onSearchClear, onSearchKeyUp }: TSearchBox) => (
<div className='db-toolbox__search'>
<Formik initialValues={{ search: '' }} onSubmit={onSearch}>
{({ submitForm, values: { search }, setFieldValue }) => (
<Form>
<FormField name='search'>
{({ field }: FieldProps<string, TFormValues>) => (
<Input
{...field}
className='db-toolbox__search-field'
type='text'
name='search'
placeholder={localize('Search')}
onKeyUp={() => onSearchKeyUp(submitForm)}
onFocus={submitForm}
onBlur={onSearchBlur}
leading_icon={
(search &&
(is_search_loading ? (
<div className='loader' />
) : (
<Icon
icon='IcCloseCircle'
onClick={() => onSearchClear(setFieldValue)}
color='secondary'
/>
))) ||
(!search && <Icon icon='IcSearch' />)
}
/>
)}
</FormField>
</Form>
)}
</Formik>
</div>
);

export default SearchBox;
Loading

0 comments on commit 11f2572

Please sign in to comment.