tycho-components 0.18.0 → 0.18.2

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.
@@ -133,6 +133,10 @@
133
133
  .header-profile-apps {
134
134
  display: block;
135
135
  margin-left: auto;
136
+
137
+ > .profile-container {
138
+ display: flex;
139
+ }
136
140
  }
137
141
  }
138
142
 
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { IconButton } from 'tycho-storybook';
@@ -14,5 +14,5 @@ export default function HeaderButtons({ hideKeyboard, notifications, keyboardLay
14
14
  const { getCorpus } = useCorpusUtils();
15
15
  const { isLogged } = useLoggedUtils();
16
16
  const [openKeyboard, setOpenKeyboard] = useState(false);
17
- return (_jsxs(_Fragment, { children: [!hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard'), mode: mobile ? 'outlined' : 'filled' })), _jsx(HelpButton, { helpActions: helpActions, mobile: mobile }), notifications && isLogged() && (_jsx(HeaderNotifications, { uid: notifications.ref, mode: notifications.mode, mobile: mobile })), _jsx(LanguageSelector, { openToTop: mobile ? true : false, mobile: mobile }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: keyboardLayout || getCorpus().keyboardLayout || 'english' }))] }));
17
+ return (_jsxs("div", { className: "header-buttons", children: [!hideKeyboard && (_jsx(IconButton, { onClick: () => setOpenKeyboard(!openKeyboard), name: "keyboard", size: "medium", title: t('tooltip.keyboard'), mode: mobile ? 'outlined' : 'filled' })), _jsx(HelpButton, { helpActions: helpActions, mobile: mobile }), notifications && isLogged() && (_jsx(HeaderNotifications, { uid: notifications.ref, mode: notifications.mode, mobile: mobile })), _jsx(LanguageSelector, { openToTop: mobile ? true : false, mobile: mobile }), openKeyboard && (_jsx(VirtualKeyboard, { onClose: () => setOpenKeyboard(false), closeLabel: t('button.close'), defaultLayout: keyboardLayout || getCorpus().keyboardLayout || 'english' }))] }));
18
18
  }
@@ -0,0 +1,11 @@
1
+ .header-buttons {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 8px;
5
+ }
6
+
7
+ @media (max-width: 768px) {
8
+ .header-buttons {
9
+ display: none;
10
+ }
11
+ }
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { Button, Icon, ProfileDropdown } from 'tycho-storybook';
4
+ import { Avatar, Button, Icon } from 'tycho-storybook';
5
5
  import { useLoggedUtils } from '../../configs/useLoggedUtils';
6
6
  import './style.scss';
7
7
  export default function HeaderUser({ navigateLogout, navigateNotLogged, }) {
@@ -12,7 +12,7 @@ export default function HeaderUser({ navigateLogout, navigateNotLogged, }) {
12
12
  setOpen(false);
13
13
  window.open(import.meta.env.VITE_APP_RESERVED_URL, '_blank');
14
14
  };
15
- return (_jsxs("div", { className: "profile-container", children: [isLogged() ? (_jsx(ProfileDropdown, { src: getLogged()?.picture, title: getLogged()?.name || getLogged()?.sub, onClick: (b) => setOpen(b) })) : (_jsx(Button, { text: t('button.sign.in'), size: "small", onClick: navigateNotLogged })), open && isLogged() && (_jsxs("div", { className: "ds-dropdown-list", children: [_jsx("div", { className: "ds-dropdown-itemlist", children: _jsx("span", { className: "label", children: `${t('profile.label.hello')} ${getLogged()?.name || getLogged()?.sub}` }) }), _jsxs("div", { className: "ds-dropdown-itemlist d-none", children: [_jsx(Icon, { name: "colors", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.theme') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", onClick: handleProfile, children: [_jsx(Icon, { name: "person", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.home') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", children: [_jsx(Icon, { name: "live_help", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.help') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", onClick: () => {
15
+ return (_jsxs("div", { className: "profile-container", children: [isLogged() ? (_jsx("div", { onClick: () => setOpen(!open), children: _jsx(Avatar, { size: "small", src: getLogged()?.picture, title: getLogged()?.name || getLogged()?.sub }) })) : (_jsx(Button, { text: t('button.sign.in'), size: "small", onClick: navigateNotLogged })), open && isLogged() && (_jsxs("div", { className: "ds-dropdown-list", children: [_jsx("div", { className: "ds-dropdown-itemlist", children: _jsx("span", { className: "label", children: `${t('profile.label.hello')} ${getLogged()?.name || getLogged()?.sub}` }) }), _jsxs("div", { className: "ds-dropdown-itemlist d-none", children: [_jsx(Icon, { name: "colors", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.theme') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", onClick: handleProfile, children: [_jsx(Icon, { name: "person", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.home') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", children: [_jsx(Icon, { name: "live_help", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.help') })] }), _jsxs("div", { className: "ds-dropdown-itemlist", onClick: () => {
16
16
  setOpen(false);
17
17
  navigateLogout && navigateLogout();
18
18
  }, children: [_jsx(Icon, { name: "logout", size: "x-small" }), _jsx("span", { className: "label", children: t('profile.label.logout') })] })] }))] }));
@@ -24,3 +24,9 @@
24
24
  }
25
25
  }
26
26
  }
27
+
28
+ @media (max-width: 767px) {
29
+ .profile-container {
30
+ display: none;
31
+ }
32
+ }
@@ -35,7 +35,7 @@
35
35
  align-items: center;
36
36
  justify-content: flex-end;
37
37
  padding-right: var(--spacing-150);
38
- gap: 4px;
38
+ gap: 8px;
39
39
  }
40
40
  }
41
41
 
@@ -13,6 +13,7 @@ export type RedirectPageParams = {
13
13
  hasParameter: (corpus: Corpus, param: string) => boolean;
14
14
  tool?: PlatformTools;
15
15
  ctxPath?: string;
16
+ sameWindow?: boolean;
16
17
  };
17
18
  type EditionToolsMenu = {
18
19
  parameter: string;
@@ -24,7 +25,7 @@ type EditionToolsMenu = {
24
25
  };
25
26
  export declare const EDITION_TOOLS: EditionToolsMenu[];
26
27
  declare const ToolsUtils: {
27
- redirectPage: ({ corpus, uid, hasParameter, tool, ctxPath, }: RedirectPageParams) => void;
28
+ redirectPage: ({ corpus, uid, hasParameter, tool, ctxPath, sameWindow, }: RedirectPageParams) => void;
28
29
  getIcon: (defaultTool?: PlatformTools) => string;
29
30
  openDocument: ({ page, corpus, hasParameter, defaultTool, ctxPath, }: OpenDocumentParams) => void;
30
31
  getTitle: (defaultTool?: PlatformTools) => string;
@@ -47,34 +47,42 @@ const withCtxPath = (absolutePath, ctxPath) => {
47
47
  const path = absolutePath.startsWith('/') ? absolutePath : `/${absolutePath}`;
48
48
  return `${base}${path}`;
49
49
  };
50
- const openTranslations = (uid, ctxPath) => {
51
- window.open(withCtxPath(`/translation/${uid}`, ctxPath));
50
+ const navigateTo = (path, ctxPath, sameWindow) => {
51
+ const targetPath = withCtxPath(path, ctxPath);
52
+ if (sameWindow) {
53
+ window.location.assign(targetPath);
54
+ return;
55
+ }
56
+ window.open(targetPath);
57
+ };
58
+ const openTranslations = (uid, ctxPath, sameWindow) => {
59
+ navigateTo(`/translation/${uid}`, ctxPath, sameWindow);
52
60
  };
53
- const openTranscriber = (uid, ctxPath) => {
54
- window.open(withCtxPath(`/transcriber/${uid}`, ctxPath));
61
+ const openTranscriber = (uid, ctxPath, sameWindow) => {
62
+ navigateTo(`/transcriber/${uid}`, ctxPath, sameWindow);
55
63
  };
56
- const openEdictor = (uid, ctxPath) => {
57
- window.open(withCtxPath(`/editor/${uid}`, ctxPath));
64
+ const openEdictor = (uid, ctxPath, sameWindow) => {
65
+ navigateTo(`/editor/${uid}`, ctxPath, sameWindow);
58
66
  };
59
- const openDesign = (uid, ctxPath) => {
60
- window.open(withCtxPath(`/editor/box/${uid}`, ctxPath));
67
+ const openDesign = (uid, ctxPath, sameWindow) => {
68
+ navigateTo(`/editor/box/${uid}`, ctxPath, sameWindow);
61
69
  };
62
- const redirectPage = ({ corpus, uid, hasParameter, tool, ctxPath, }) => {
70
+ const redirectPage = ({ corpus, uid, hasParameter, tool, ctxPath, sameWindow, }) => {
63
71
  if (tool) {
64
- window.open(withCtxPath(`${EDITION_TOOLS.find((t) => t.name === tool)?.path}/${uid}`, ctxPath));
72
+ navigateTo(`${EDITION_TOOLS.find((t) => t.name === tool)?.path}/${uid}`, ctxPath, sameWindow);
65
73
  return;
66
74
  }
67
75
  if (hasParameter(corpus, 'useEdictor')) {
68
- openEdictor(uid, ctxPath);
76
+ openEdictor(uid, ctxPath, sameWindow);
69
77
  }
70
78
  else if (hasParameter(corpus, 'useTranslations')) {
71
- openTranslations(uid, ctxPath);
79
+ openTranslations(uid, ctxPath, sameWindow);
72
80
  }
73
81
  else if (hasParameter(corpus, 'useDesigner')) {
74
- openDesign(uid, ctxPath);
82
+ openDesign(uid, ctxPath, sameWindow);
75
83
  }
76
84
  else if (hasParameter(corpus, 'useTranscriber')) {
77
- openTranscriber(uid, ctxPath);
85
+ openTranscriber(uid, ctxPath, sameWindow);
78
86
  }
79
87
  };
80
88
  const openDocument = ({ page, corpus, hasParameter, defaultTool, ctxPath, }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.18.0",
4
+ "version": "0.18.2",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -49,7 +49,7 @@
49
49
  "react-hook-form": "^7.45.2",
50
50
  "react-i18next": "^13.0.2",
51
51
  "react-router-dom": "^6.14.2",
52
- "tycho-storybook": "0.6.3",
52
+ "tycho-storybook": "0.6.4",
53
53
  "yup": "^1.2.0"
54
54
  },
55
55
  "devDependencies": {