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

Chore: Keyboard shortcuts contextualBar rewrite #25753

Merged
merged 3 commits into from
Jun 4, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Box, Divider } from '@rocket.chat/fuselage';
import React, { ReactElement } from 'react';

type KeyboardShortcutSectionProps = {
title: string;
command: string;
};

const KeyboardShortcutSection = ({ title, command }: KeyboardShortcutSectionProps): ReactElement => (
<Box is='section' mb='x16'>
<Box fontScale='p2m' fontWeight='700'>
{title}
</Box>
<Divider />
<Box fontScale='p2'>{command}</Box>
</Box>
);

export default KeyboardShortcutSection;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { ComponentMeta, ComponentStory } from '@storybook/react';
import React from 'react';

import VerticalBar from '../../../../components/VerticalBar';
import KeyboardShortcutsWithClose from './KeyboardShortcutsWithClose';
import KeyboardShortcutsWithData from './KeyboardShortcutsWithData';

export default {
title: 'Room/Contextual Bar/KeyboardShortcut',
component: KeyboardShortcutsWithClose,
component: KeyboardShortcutsWithData,
parameters: {
layout: 'fullscreen',
},
decorators: [(fn) => <VerticalBar height='100vh'>{fn()}</VerticalBar>],
} as ComponentMeta<typeof KeyboardShortcutsWithClose>;
} as ComponentMeta<typeof KeyboardShortcutsWithData>;

export const Default: ComponentStory<typeof KeyboardShortcutsWithClose> = (args) => <KeyboardShortcutsWithClose {...args} />;
export const Default: ComponentStory<typeof KeyboardShortcutsWithData> = (args) => <KeyboardShortcutsWithData {...args} />;
Default.storyName = 'KeyboardShortcuts';
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useTranslation } from '@rocket.chat/ui-contexts';
import React, { memo, ReactElement } from 'react';

import VerticalBar from '../../../../components/VerticalBar';
import KeyboardShortcutSection from './KeyboardShortcutSection';

const KeyboardShortcuts = ({ handleClose }: { handleClose: () => void }): ReactElement => {
const t = useTranslation();

return (
<>
<VerticalBar.Header>
<VerticalBar.Icon name='keyboard' />
<VerticalBar.Text>{t('Keyboard_Shortcuts_Title')}</VerticalBar.Text>
{handleClose && <VerticalBar.Close onClick={handleClose} />}
</VerticalBar.Header>
<VerticalBar.ScrollableContent>
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_Open_Channel_Slash_User_Search')} command={t('Keyboard_Shortcuts_Keys_1')} />
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_Mark_all_as_read')} command={t('Keyboard_Shortcuts_Keys_8')} />
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_Edit_Previous_Message')} command={t('Keyboard_Shortcuts_Keys_2')} />
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_Move_To_Beginning_Of_Message')} command={t('Keyboard_Shortcuts_Keys_3')} />
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_Move_To_Beginning_Of_Message')} command={t('Keyboard_Shortcuts_Keys_4')} />
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_Move_To_End_Of_Message')} command={t('Keyboard_Shortcuts_Keys_5')} />
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_Move_To_End_Of_Message')} command={t('Keyboard_Shortcuts_Keys_6')} />
<KeyboardShortcutSection title={t('Keyboard_Shortcuts_New_Line_In_Message')} command={t('Keyboard_Shortcuts_Keys_7')} />
</VerticalBar.ScrollableContent>
</>
);
};

export default memo(KeyboardShortcuts);

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import React, { ReactElement } from 'react';

import { ToolboxContextValue } from '../../lib/Toolbox/ToolboxContext';
import KeyboardShortcuts from './KeyboardShortcuts';

const KeyboardShortcutsWithData = ({ tabBar }: { tabBar: ToolboxContextValue['tabBar'] }): ReactElement => {
const handleClose = useMutableCallback(() => tabBar?.close());
return <KeyboardShortcuts handleClose={handleClose} />;
};

export default KeyboardShortcutsWithData;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './KeyboardShortcutsWithClose';
export { default } from './KeyboardShortcutsWithData';