@dxos/plugin-status-bar 0.7.5-main.9d2a38b → 0.7.5-main.e9bb01b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,19 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Capabilities, contributes, createSurface, defineModule, definePlugin, Events } from '@dxos/app-framework';
7
+ import {
8
+ Capabilities,
9
+ contributes,
10
+ createSurface,
11
+ defineModule,
12
+ definePlugin,
13
+ Events,
14
+ Surface,
15
+ } from '@dxos/app-framework';
8
16
 
9
- import { StatusBarPanel } from './components';
10
- import { meta } from './meta';
17
+ import { StatusBarActions, StatusBarPanel } from './components';
18
+ import { VersionNumber } from './components/VersionNumber';
19
+ import { meta, STATUS_BAR_PLUGIN } from './meta';
11
20
  import translations from './translations';
12
21
 
13
22
  export const StatusBarPlugin = () =>
@@ -19,7 +28,7 @@ export const StatusBarPlugin = () =>
19
28
  }),
20
29
  defineModule({
21
30
  id: `${meta.id}/module/react-surface`,
22
- activatesOn: Events.Startup,
31
+ activatesOn: Events.SetupSurfaces,
23
32
  activate: () =>
24
33
  contributes(Capabilities.ReactSurface, [
25
34
  createSurface({
@@ -29,8 +38,18 @@ export const StatusBarPlugin = () =>
29
38
  }),
30
39
  createSurface({
31
40
  id: meta.id,
32
- role: 'status-bar--sidebar-footer',
33
- component: () => <StatusBarPanel />,
41
+ role: 'status-bar--r0-footer',
42
+ component: () => <Surface role='status' />,
43
+ }),
44
+ createSurface({
45
+ id: meta.id,
46
+ role: 'status-bar--r1-footer',
47
+ component: () => <StatusBarActions />,
48
+ }),
49
+ createSurface({
50
+ id: `${STATUS_BAR_PLUGIN}/header-end`,
51
+ role: 'header-end',
52
+ component: () => <VersionNumber />,
34
53
  }),
35
54
  ]),
36
55
  }),
@@ -13,7 +13,7 @@ import { withTheme } from '@dxos/storybook-utils';
13
13
  import { StatusBar } from './StatusBar';
14
14
 
15
15
  export const DefaultStory = () => (
16
- <StatusBar.Container>
16
+ <div>
17
17
  <StatusBar.EndContent>
18
18
  <StatusBar.Button>
19
19
  <Icon icon='ph--mailbox--regular' size={4} />
@@ -30,7 +30,7 @@ export const DefaultStory = () => (
30
30
  <StatusBar.Text>Online</StatusBar.Text>
31
31
  </StatusBar.Item>
32
32
  </StatusBar.EndContent>
33
- </StatusBar.Container>
33
+ </div>
34
34
  );
35
35
 
36
36
  export const Default = {};
@@ -2,9 +2,8 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { useFocusableGroup } from '@fluentui/react-tabster';
6
5
  import { Slot } from '@radix-ui/react-slot';
7
- import React, { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
6
+ import React, { type ComponentPropsWithRef, forwardRef, type PropsWithChildren, type ReactNode } from 'react';
8
7
 
9
8
  import { type ThemedClassName } from '@dxos/react-ui';
10
9
  import { mx } from '@dxos/react-ui-theme';
@@ -17,14 +16,13 @@ const StatusBarText = forwardRef<HTMLSpanElement, StatusBarTextProps>(({ classNa
17
16
  </span>
18
17
  ));
19
18
 
20
- type StatusBarButtonProps = ThemedClassName<{ children: ReactNode; asChild?: boolean }> &
21
- HTMLAttributes<HTMLButtonElement>;
19
+ type StatusBarButtonProps = ThemedClassName<ComponentPropsWithRef<'button'> & { asChild?: boolean }>;
22
20
 
23
21
  const StatusBarButton = forwardRef<HTMLButtonElement, StatusBarButtonProps>(
24
22
  ({ classNames, children, asChild, ...props }, forwardedRef) => {
25
23
  const classes = mx(
26
- 'flex items-center gap-2 p-1 px-2 rounded-sm',
27
- 'select-none cursor-pointer ch-focus-ring',
24
+ 'flex items-center justify-center gap-2 p-1 px-2 rounded-sm',
25
+ 'select-none cursor-pointer dx-focus-ring text-description text-xs',
28
26
  'hover:bg-neutral-75 active:bg-neutral-150 dark:hover:bg-neutral-750 dark:active:bg-neutral-700',
29
27
  classNames,
30
28
  );
@@ -43,13 +41,13 @@ const StatusBarButton = forwardRef<HTMLButtonElement, StatusBarButtonProps>(
43
41
 
44
42
  export default StatusBarButton;
45
43
 
46
- type StatusBarItemProps = ThemedClassName<{ children: ReactNode }> & HTMLAttributes<HTMLDivElement>;
44
+ type StatusBarItemProps = ThemedClassName<ComponentPropsWithRef<'div'>>;
47
45
 
48
46
  const StatusBarItem = forwardRef<HTMLDivElement, StatusBarItemProps>(
49
47
  ({ classNames, children, ...props }, forwardedRef) => (
50
48
  <div
51
49
  role='menuitem'
52
- className={mx('flex items-center gap-2 p-1 px-2 rounded-sm select-none', classNames)}
50
+ className={mx('flex items-center justify-center gap-2 p-1 px-2 rounded-sm select-none', classNames)}
53
51
  ref={forwardedRef}
54
52
  {...props}
55
53
  >
@@ -58,30 +56,7 @@ const StatusBarItem = forwardRef<HTMLDivElement, StatusBarItemProps>(
58
56
  ),
59
57
  );
60
58
 
61
- type StatusBarContainerProps = ThemedClassName<{ children: ReactNode }>;
62
-
63
- // TODO(zan): tabable group with tabster.
64
- const StatusBarContainer = forwardRef<HTMLDivElement, StatusBarContainerProps>(
65
- ({ classNames, children }, forwardedRef) => {
66
- const groupAttrs = useFocusableGroup({ tabBehavior: 'limited' });
67
- return (
68
- <div
69
- role='menubar'
70
- tabIndex={0}
71
- {...groupAttrs}
72
- className={mx(
73
- 'bs-[--statusbar-size] flex justify-end items-center gap-2 bg-base text-description text-lg pointer-fine:text-xs ch-focus-ring-inset',
74
- classNames,
75
- )}
76
- ref={forwardedRef}
77
- >
78
- {children}
79
- </div>
80
- );
81
- },
82
- );
83
-
84
- type StartContentProps = ThemedClassName<{ children: ReactNode }>;
59
+ type StartContentProps = ThemedClassName<PropsWithChildren<{}>>;
85
60
 
86
61
  const StartContent = forwardRef<HTMLDivElement, StartContentProps>(({ classNames, children }, forwardedRef) => (
87
62
  <div role='none' className={mx('flex-grow flex items-center space-x-2', classNames)} ref={forwardedRef}>
@@ -89,7 +64,7 @@ const StartContent = forwardRef<HTMLDivElement, StartContentProps>(({ classNames
89
64
  </div>
90
65
  ));
91
66
 
92
- type EndContentProps = ThemedClassName<{ children: ReactNode }>;
67
+ type EndContentProps = ThemedClassName<PropsWithChildren<{}>>;
93
68
 
94
69
  const EndContent = forwardRef<HTMLDivElement, EndContentProps>(({ classNames, children }, forwardedRef) => (
95
70
  <div role='none' className={mx('flex-grow flex items-center justify-end', classNames)} ref={forwardedRef}>
@@ -98,7 +73,6 @@ const EndContent = forwardRef<HTMLDivElement, EndContentProps>(({ classNames, ch
98
73
  ));
99
74
 
100
75
  export const StatusBar = {
101
- Container: StatusBarContainer,
102
76
  Text: StatusBarText,
103
77
  Item: StatusBarItem,
104
78
  Button: StatusBarButton,
@@ -5,39 +5,48 @@
5
5
  import React, { useState } from 'react';
6
6
 
7
7
  import { Surface } from '@dxos/app-framework';
8
- import { Icon, Popover } from '@dxos/react-ui';
8
+ import { Icon, Popover, useTranslation } from '@dxos/react-ui';
9
9
 
10
10
  import { FeedbackForm } from './FeedbackForm';
11
11
  import { StatusBar } from './StatusBar';
12
+ import { VersionNumber } from './VersionNumber';
13
+ import { STATUS_BAR_PLUGIN } from '../meta';
12
14
 
13
- export const StatusBarPanel = () => {
15
+ export const StatusBarActions = () => {
16
+ const { t } = useTranslation(STATUS_BAR_PLUGIN);
14
17
  const [open, setOpen] = useState(false);
15
-
16
- // TODO(wittjosiah): Factor out feedback and discord buttons.
17
18
  return (
18
19
  <Popover.Root open={open} onOpenChange={setOpen}>
19
- <StatusBar.Container>
20
- <StatusBar.EndContent>
21
- <Surface role='status' />
22
- <Popover.Trigger asChild>
23
- <StatusBar.Button aria-label='Give feedback about composer' data-joyride='welcome/feedback'>
24
- <Icon icon='ph--paper-plane-tilt--regular' size={4} />
25
- <StatusBar.Text classNames='hidden sm:block'>Feedback</StatusBar.Text>
26
- </StatusBar.Button>
27
- </Popover.Trigger>
28
- {/* TODO(zan): Configure this label? */}
29
- <StatusBar.Button aria-label='Open DXOS Discord' asChild>
30
- <a href='https://dxos.org/discord' target='_blank' rel='noopener noreferrer'>
31
- <Icon icon='ph--discord-logo--regular' size={4} />
32
- <StatusBar.Text classNames='hidden sm:block'>Discord</StatusBar.Text>
33
- </a>
34
- </StatusBar.Button>
35
- </StatusBar.EndContent>
36
- </StatusBar.Container>
37
- <Popover.Content classNames='shadow-lg'>
38
- <FeedbackForm onClose={() => setOpen(false)} />
39
- <Popover.Arrow />
40
- </Popover.Content>
20
+ <Popover.Trigger asChild>
21
+ <StatusBar.Button data-joyride='welcome/feedback'>
22
+ <Icon icon='ph--paper-plane-tilt--regular' size={4} />
23
+ <StatusBar.Text classNames='hidden sm:block'>{t('feedback label')}</StatusBar.Text>
24
+ </StatusBar.Button>
25
+ </Popover.Trigger>
26
+ {/* TODO(zan): Configure this label? */}
27
+ <StatusBar.Button asChild>
28
+ <a href='https://dxos.org/discord' target='_blank' rel='noopener noreferrer'>
29
+ <Icon icon='ph--discord-logo--regular' size={4} />
30
+ <StatusBar.Text classNames='hidden sm:block'>{t('discord label')}</StatusBar.Text>
31
+ </a>
32
+ </StatusBar.Button>
33
+ <VersionNumber />
34
+ <Popover.Portal>
35
+ <Popover.Content classNames='shadow-lg'>
36
+ <FeedbackForm onClose={() => setOpen(false)} />
37
+ <Popover.Arrow />
38
+ </Popover.Content>
39
+ </Popover.Portal>
41
40
  </Popover.Root>
42
41
  );
43
42
  };
43
+
44
+ export const StatusBarPanel = () => {
45
+ return (
46
+ <>
47
+ <StatusBarActions />
48
+ <span role='separator' className='grow' />
49
+ <Surface role='status' />
50
+ </>
51
+ );
52
+ };
@@ -0,0 +1,86 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { formatDistance } from 'date-fns/formatDistance';
6
+ import React from 'react';
7
+
8
+ import { useConfig } from '@dxos/react-client';
9
+ import { Link, Message, Popover, Trans, useTranslation, Icon } from '@dxos/react-ui';
10
+
11
+ import { StatusBar } from './StatusBar';
12
+ import { STATUS_BAR_PLUGIN } from '../meta';
13
+
14
+ const repo = 'https://github.com/dxos/dxos';
15
+
16
+ const VERSION_REGEX = /([\d.]+)/;
17
+
18
+ export const VersionNumber = () => {
19
+ const config = useConfig();
20
+ const { t } = useTranslation(STATUS_BAR_PLUGIN);
21
+ const { version, timestamp, commitHash } = config.values.runtime?.app?.build ?? {};
22
+ const [_, v] = version?.match(VERSION_REGEX) ?? [];
23
+
24
+ const releaseUrl =
25
+ config.values.runtime?.app?.env?.DX_ENVIRONMENT === 'production'
26
+ ? `${repo}/releases/tag/v${version}`
27
+ : `${repo}/commit/${commitHash}`;
28
+
29
+ const previewUrl = 'https://docs.dxos.org/composer#technology-preview';
30
+
31
+ return (
32
+ <Popover.Root>
33
+ <Popover.Trigger asChild>
34
+ <StatusBar.Button classNames='text-xs'>v{v}</StatusBar.Button>
35
+ </Popover.Trigger>
36
+ <Popover.Portal>
37
+ <Popover.Content
38
+ side='top'
39
+ role='message'
40
+ classNames='z-[12] bg-warning-500 max-is-[min(calc(100vw-16px),40ch)]'
41
+ >
42
+ <Message.Root valence='warning' className='rounded-be-none p-5'>
43
+ <Message.Title>
44
+ <Icon icon='ph--warning--duotone' size={6} classNames='inline mie-2' />
45
+ <span>{t('warning title')}</span>
46
+ </Message.Title>
47
+ <Message.Body>
48
+ {t('technology preview message')}
49
+ <br />
50
+ <Link href={previewUrl} target='_blank' rel='noreferrer' variant='neutral'>
51
+ {t('learn more label')}
52
+ <Icon icon='ph--arrow-square-out--bold' classNames='inline mis-1' />
53
+ </Link>
54
+ </Message.Body>
55
+ </Message.Root>
56
+ <div role='none' className='plb-4 pli-5 space-b-2 text-baseText'>
57
+ {timestamp && (
58
+ <p>
59
+ {t('released message', {
60
+ released: formatDistance(new Date(timestamp), new Date(), { addSuffix: true }),
61
+ })}
62
+ <br />
63
+ <Link href={releaseUrl} target='_blank' rel='noreferrer' variant='neutral'>
64
+ {t('see release label')}
65
+ <Icon icon='ph--arrow-square-out--bold' classNames='inline mis-1' />
66
+ </Link>
67
+ </p>
68
+ )}
69
+ <p>
70
+ <Trans
71
+ {...{
72
+ t,
73
+ i18nKey: 'powered by dxos message',
74
+ components: {
75
+ dxos: <Link href='https://dxos.org' target='_blank' rel='noreferrer' variant='neutral' />,
76
+ },
77
+ }}
78
+ />
79
+ </p>
80
+ </div>
81
+ <Popover.Arrow />
82
+ </Popover.Content>
83
+ </Popover.Portal>
84
+ </Popover.Root>
85
+ );
86
+ };
@@ -14,7 +14,15 @@ type StatusBarTranslationKeys =
14
14
  | 'feedback text area placeholder'
15
15
  | 'send feedback label'
16
16
  | 'name label'
17
- | 'name placeholder';
17
+ | 'name placeholder'
18
+ | 'warning title'
19
+ | 'technology preview message'
20
+ | 'learn more label'
21
+ | 'released message'
22
+ | 'see release label'
23
+ | 'powered by dxos message'
24
+ | 'discord label'
25
+ | 'feedback label';
18
26
 
19
27
  type RequiredTranslation = { [key in StatusBarTranslationKeys]: string };
20
28
  type TranslationEntry = { [STATUS_BAR_PLUGIN]: RequiredTranslation };
@@ -34,6 +42,14 @@ const translations: Record<Language, TranslationEntry> = {
34
42
  'feedback text area label': 'Feedback',
35
43
  'feedback text area placeholder': 'Found a bug? Have a suggestion? Let us know!',
36
44
  'send feedback label': 'Send Feedback',
45
+ 'warning title': 'WARNING',
46
+ 'technology preview message': 'Composer is still in technology preview.',
47
+ 'learn more label': 'Learn more',
48
+ 'released message': 'This version released {{released}}.',
49
+ 'see release label': 'See release on GitHub',
50
+ 'powered by dxos message': 'Powered by <dxos>DXOS</dxos>',
51
+ 'discord label': 'Discord',
52
+ 'feedback label': 'Feedback',
37
53
  }),
38
54
  };
39
55