lupine.web 1.0.15 → 1.0.16
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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/components/menu-bar.tsx +1 -1
- package/src/components/menu-sidebar.tsx +1 -1
- package/src/components/meta-data.tsx +6 -24
- package/src/components/meta-description.tsx +3 -10
- package/src/components/page-title.tsx +6 -0
- package/src/components/panel.tsx +1 -4
- package/src/components/tabs.tsx +1 -1
- package/src/components/theme-selector.tsx +0 -3
- package/src/core/bind-meta.tsx +52 -0
- package/src/core/bind-theme.ts +5 -4
- package/src/core/core.ts +4 -13
- package/src/core/index.ts +1 -0
- package/src/index.ts +2 -2
- package/src/models/index.ts +2 -0
- package/src/models/json-props.ts +8 -0
- package/src/models/theme-props.ts +7 -0
- package/src/{assets/themes → styles}/base-themes.ts +2 -1
- package/src/{assets/themes → styles}/dark-themes.ts +2 -1
- package/src/styles/index.ts +9 -0
- package/src/{assets/themes → styles}/light-themes.ts +2 -1
- package/src/{assets/themes → styles}/shared-themes.ts +3 -1
- package/src/assets/themes/index.ts +0 -4
- package/src/components/meta-title.tsx +0 -19
- package/src/types/css-types.ts +0 -17
- package/src/types/index.ts +0 -6
- /package/src/{types → styles}/css-styles.ts +0 -0
- /package/src/{types → styles}/media-query.ts +0 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getRenderPageProps } from '../core';
|
|
2
2
|
import { RefProps } from '../jsx';
|
|
3
|
-
import { MediaQueryMaxWidth } from '../
|
|
3
|
+
import { MediaQueryMaxWidth } from '../styles';
|
|
4
4
|
import { LinkItem } from './link-item';
|
|
5
5
|
import { NestMenuItemProps } from './menu-item-props';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { bindGlobalStyles, getRenderPageProps } from '../core';
|
|
2
2
|
import { CssProps, RefProps } from '../jsx';
|
|
3
3
|
import { stopPropagation } from '../lib';
|
|
4
|
-
import { MediaQueryMaxWidth } from '../
|
|
4
|
+
import { MediaQueryMaxWidth } from '../styles';
|
|
5
5
|
import { NestMenuItemProps } from './menu-item-props';
|
|
6
6
|
|
|
7
7
|
const fetchMenu = async (menuId: string) => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// import { bindPageResetEvent } from '../core/page-reset-events';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { addMetaDataTags } from '../core/bind-meta';
|
|
4
3
|
type NameMeta = { name: string; content: string };
|
|
5
4
|
type PropertyMeta = { property: string; content: string };
|
|
6
5
|
type HttpEquivMeta = { httpEquiv: string; content: string };
|
|
@@ -16,39 +15,22 @@ function isHttpEquivMeta(data: any): data is HttpEquivMeta {
|
|
|
16
15
|
return !!(data.httpEquiv && data.content);
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
// Shouldn't include <meta name="description" content="...">
|
|
18
|
+
// should use description tag instead of meta tag ( <meta name="description" content="..."> )
|
|
21
19
|
export const MetaData = (data: AllMeta) => {
|
|
22
20
|
if (isNameMeta(data)) {
|
|
23
|
-
|
|
21
|
+
addMetaDataTags(`name:${data.name}`, `<meta name="${data.name}" content="${data.content}">`);
|
|
24
22
|
} else if (isPropertyMeta(data)) {
|
|
25
|
-
|
|
23
|
+
addMetaDataTags(`property:${data.property}`, `<meta property="${data.property}" content="${data.content}">`);
|
|
26
24
|
} else if (isHttpEquivMeta(data)) {
|
|
27
|
-
|
|
25
|
+
addMetaDataTags(`http-equiv:${data.httpEquiv}`, `<meta http-equiv="${data.httpEquiv}" content="${data.content}">`);
|
|
28
26
|
} else if ((data as any).key && (data as any).string) {
|
|
29
|
-
|
|
27
|
+
addMetaDataTags(`${(data as any).key}`, `${(data as any).string}`);
|
|
30
28
|
} else {
|
|
31
29
|
console.warn('Unknown meta data:', data);
|
|
32
30
|
}
|
|
33
31
|
return <></>;
|
|
34
32
|
};
|
|
35
33
|
|
|
36
|
-
export const getMetaDataTags = () => {
|
|
37
|
-
return Object.values(getMetaDataObject()).join('\n');
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const getMetaDataObject = () => {
|
|
41
|
-
const metaDescription = getMetaDescription();
|
|
42
|
-
return metaDescription
|
|
43
|
-
? Object.assign(
|
|
44
|
-
{
|
|
45
|
-
'name:description': `<meta name="description" content="${metaDescription}">`,
|
|
46
|
-
},
|
|
47
|
-
_metaData
|
|
48
|
-
)
|
|
49
|
-
: _metaData;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
34
|
// bindPageResetEvent(() => {
|
|
53
35
|
// _metaData = {};
|
|
54
36
|
// });
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
// import { bindPageResetEvent } from '../core/page-reset-events';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { addMetaDataTags } from "../core/bind-meta";
|
|
4
|
+
|
|
4
5
|
export const MetaDescription = ({ children }: { children: string }) => {
|
|
5
|
-
|
|
6
|
+
addMetaDataTags('name:description', `<meta name="description" content="${children}">`);
|
|
6
7
|
return <></>;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
export const getMetaDescription = () => {
|
|
10
|
-
return _description.value || _description.defaultValue;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const setDefaultMetaDescription = (children: string) => {
|
|
14
|
-
_description.defaultValue = children;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
10
|
// bindPageResetEvent(() => {
|
|
18
11
|
// _description.value = '';
|
|
19
12
|
// });
|
package/src/components/panel.tsx
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { CssProps
|
|
2
|
-
import { ContentPosition, Position } from '../types';
|
|
1
|
+
import { CssProps } from '../jsx';
|
|
3
2
|
|
|
4
3
|
export type PanelProps = {
|
|
5
4
|
children: any;
|
|
6
5
|
className?: string;
|
|
7
|
-
contentPosition?: ContentPosition;
|
|
8
6
|
css?: CssProps;
|
|
9
7
|
};
|
|
10
8
|
|
|
@@ -12,7 +10,6 @@ export const Panel = ({ children, className, css }: PanelProps) => {
|
|
|
12
10
|
const newCss: CssProps = {
|
|
13
11
|
display: 'flex',
|
|
14
12
|
flexDirection: 'column',
|
|
15
|
-
// justifyContent: ContentPosition.center,
|
|
16
13
|
...css,
|
|
17
14
|
};
|
|
18
15
|
|
package/src/components/tabs.tsx
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { bindGlobalStyles, getCurrentTheme, updateTheme } from '../core';
|
|
2
2
|
import { CssProps } from '../jsx';
|
|
3
|
-
import { ContentPosition } from '../types';
|
|
4
3
|
import { PopupMenu } from './popup-menu';
|
|
5
4
|
|
|
6
5
|
export type ThemeSelectorProps = {
|
|
7
6
|
className?: string;
|
|
8
|
-
contentPosition?: ContentPosition;
|
|
9
7
|
css?: CssProps;
|
|
10
8
|
};
|
|
11
9
|
|
|
@@ -14,7 +12,6 @@ export const ThemeSelector = ({ className, css }: ThemeSelectorProps) => {
|
|
|
14
12
|
display: 'flex',
|
|
15
13
|
flexDirection: 'column',
|
|
16
14
|
alignSelf: 'end',
|
|
17
|
-
// justifyContent: ContentPosition.center,
|
|
18
15
|
...css,
|
|
19
16
|
};
|
|
20
17
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// import { bindPageResetEvent } from '../core/page-reset-events';
|
|
2
|
+
|
|
3
|
+
let _pageTitle = { value: '', defaultValue: '' };
|
|
4
|
+
export const setPageTitle = (title: string) => {
|
|
5
|
+
_pageTitle.value = title;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const getPageTitle = () => {
|
|
9
|
+
return _pageTitle.value || _pageTitle.defaultValue;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const setDefaultPageTitle = (title: string) => {
|
|
13
|
+
_pageTitle.defaultValue = title;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let _description = { value: '', defaultValue: '' };
|
|
17
|
+
export const setMetaDescription = (description: string) => {
|
|
18
|
+
_description.value = description;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const getMetaDescription = () => {
|
|
22
|
+
return _description.value || _description.defaultValue;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const setDefaultMetaDescription = (description: string) => {
|
|
26
|
+
_description.defaultValue = description;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let _metaData: { [key: string]: string } = {};
|
|
30
|
+
export const addMetaDataTags = (key: string, value: string) => {
|
|
31
|
+
if (typeof value === 'undefined') {
|
|
32
|
+
delete _metaData[key];
|
|
33
|
+
} else {
|
|
34
|
+
_metaData[key] = value;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getMetaDataTags = () => {
|
|
39
|
+
return Object.values(getMetaDataObject()).join('\n');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const getMetaDataObject = () => {
|
|
43
|
+
const metaDescription = getMetaDescription();
|
|
44
|
+
return metaDescription
|
|
45
|
+
? Object.assign(
|
|
46
|
+
{
|
|
47
|
+
'name:description': `<meta name="description" content="${metaDescription}">`,
|
|
48
|
+
},
|
|
49
|
+
_metaData
|
|
50
|
+
)
|
|
51
|
+
: _metaData;
|
|
52
|
+
};
|
package/src/core/bind-theme.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CssProps } from '../jsx';
|
|
2
1
|
import { DomUtils } from '../lib';
|
|
2
|
+
import { ThemesProps } from '../models';
|
|
3
3
|
import { getEitherCookie } from './server-cookie';
|
|
4
4
|
|
|
5
5
|
// theme doesn't need to reset, theme name is stored in cookie
|
|
@@ -8,8 +8,8 @@ export const defaultThemeName = 'light';
|
|
|
8
8
|
export const themeCookieName = 'theme';
|
|
9
9
|
export const updateThemeEventName = 'updateTheme';
|
|
10
10
|
export const themeAttributeName = 'data-theme';
|
|
11
|
-
const _themeCfg:
|
|
12
|
-
export const bindTheme = (defaultTheme: string, themes:
|
|
11
|
+
const _themeCfg: { defaultTheme: string; themes: ThemesProps } = { defaultTheme: defaultThemeName, themes: {} };
|
|
12
|
+
export const bindTheme = (defaultTheme: string, themes: ThemesProps) => {
|
|
13
13
|
_themeCfg.defaultTheme = defaultTheme;
|
|
14
14
|
_themeCfg.themes = themes;
|
|
15
15
|
|
|
@@ -25,7 +25,7 @@ export const getCurrentTheme = () => {
|
|
|
25
25
|
DomUtils.setCookie(themeCookieName, _themeCfg.defaultTheme);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
return { themeName, themes: _themeCfg.themes
|
|
28
|
+
return { themeName, themes: _themeCfg.themes };
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export const updateTheme = (themeName: string) => {
|
|
@@ -39,6 +39,7 @@ export const updateTheme = (themeName: string) => {
|
|
|
39
39
|
document.documentElement.setAttribute(themeAttributeName, themeName);
|
|
40
40
|
|
|
41
41
|
// update theme for all iframe
|
|
42
|
+
// TODO: third-party domains?
|
|
42
43
|
const allIframe = document.querySelectorAll('iframe');
|
|
43
44
|
for (let i = 0; i < allIframe.length; i++) {
|
|
44
45
|
if (allIframe[i].contentWindow && allIframe[i].contentWindow!.top === window) {
|
package/src/core/core.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getMetaDataObject, getMetaDataTags, getMetaTitle } from '../components';
|
|
2
1
|
import { VNode } from '../jsx';
|
|
3
2
|
import { initWebEnv, initWebSetting } from '../lib';
|
|
4
3
|
import { Logger } from '../lib/logger';
|
|
@@ -9,16 +8,8 @@ import { mountComponents } from './mount-components';
|
|
|
9
8
|
import { PageRouter } from './page-router';
|
|
10
9
|
import { callPageLoadedEvent } from './page-loaded-events';
|
|
11
10
|
import { initServerCookies } from './server-cookie';
|
|
12
|
-
import { IToClientDelivery } from '../models
|
|
13
|
-
|
|
14
|
-
export type JsonKeyValue = {
|
|
15
|
-
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
16
|
-
};
|
|
17
|
-
export type JsonObject =
|
|
18
|
-
| JsonKeyValue[]
|
|
19
|
-
| {
|
|
20
|
-
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
21
|
-
};
|
|
11
|
+
import { IToClientDelivery, JsonObject } from '../models';
|
|
12
|
+
import { getMetaDataObject, getMetaDataTags, getPageTitle } from './bind-meta';
|
|
22
13
|
|
|
23
14
|
export type RenderPageFunctionsType = {
|
|
24
15
|
fetchData: (url: string, postBody?: string | JsonObject, returnRawResponse?: boolean) => Promise<any>;
|
|
@@ -118,7 +109,7 @@ export const generatePage = async (props: PageProps, toClientDelivery: IToClient
|
|
|
118
109
|
|
|
119
110
|
return {
|
|
120
111
|
content,
|
|
121
|
-
title:
|
|
112
|
+
title: getPageTitle(),
|
|
122
113
|
metaData: getMetaDataTags(),
|
|
123
114
|
globalCss: cssText,
|
|
124
115
|
themeName: currentTheme.themeName,
|
|
@@ -165,7 +156,7 @@ export const initializePage = async (newUrl?: string) => {
|
|
|
165
156
|
updateTheme(getCurrentTheme().themeName);
|
|
166
157
|
|
|
167
158
|
// title
|
|
168
|
-
document.title =
|
|
159
|
+
document.title = getPageTitle();
|
|
169
160
|
const metaData = getMetaDataObject();
|
|
170
161
|
// meta data?
|
|
171
162
|
};
|
package/src/core/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ export * from './jsx';
|
|
|
5
5
|
export * from './core';
|
|
6
6
|
export * from './lib';
|
|
7
7
|
export * from './components';
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
8
|
+
export * from './models';
|
|
9
|
+
export * from './styles';
|
|
10
10
|
|
|
11
11
|
declare global {
|
|
12
12
|
namespace JSX {
|
package/src/models/index.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type JsonKeyValue = {
|
|
2
|
+
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
3
|
+
};
|
|
4
|
+
export type JsonObject =
|
|
5
|
+
| JsonKeyValue[]
|
|
6
|
+
| {
|
|
7
|
+
[key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
|
|
8
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { ThemesProps } from '../models';
|
|
1
2
|
import { darkThemes } from './dark-themes';
|
|
2
3
|
import { lightThemes } from './light-themes';
|
|
3
4
|
|
|
4
|
-
export const baseThemes:
|
|
5
|
+
export const baseThemes: ThemesProps = {
|
|
5
6
|
light: lightThemes,
|
|
6
7
|
dark: darkThemes,
|
|
7
8
|
lightGreen: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CssProps } from '../jsx';
|
|
2
|
+
export { CssProps as CSS };
|
|
3
|
+
|
|
4
|
+
export * from './css-styles';
|
|
5
|
+
export * from './media-query';
|
|
6
|
+
export * from './shared-themes';
|
|
7
|
+
export * from './dark-themes';
|
|
8
|
+
export * from './light-themes';
|
|
9
|
+
export * from './base-themes';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// import { bindPageResetEvent } from '../core/page-reset-events';
|
|
2
|
-
|
|
3
|
-
let _title = { value: '', defaultValue: '' };
|
|
4
|
-
export const MetaTitle = ({ children }: { children: string }) => {
|
|
5
|
-
_title.value = children;
|
|
6
|
-
return <></>;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const getMetaTitle = () => {
|
|
10
|
-
return _title.value || _title.defaultValue;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const setDefaultMetaTitle = (children: string) => {
|
|
14
|
-
_title.defaultValue = children;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// bindPageResetEvent(() => {
|
|
18
|
-
// _title.value = '';
|
|
19
|
-
// });
|
package/src/types/css-types.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export enum ContentPosition {
|
|
2
|
-
center = 'center',
|
|
3
|
-
end = 'end',
|
|
4
|
-
flexEnd = 'flex-end',
|
|
5
|
-
flexStart = 'flex-start',
|
|
6
|
-
start = 'start',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export type SelfPosition = 'center' | 'end' | 'flex-end' | 'flex-start' | 'self-end' | 'self-start' | 'start';
|
|
10
|
-
|
|
11
|
-
export enum Position {
|
|
12
|
-
absolute = 'absolute',
|
|
13
|
-
fixed = 'fixed',
|
|
14
|
-
relative = 'relative',
|
|
15
|
-
static = 'static',
|
|
16
|
-
sticky = 'sticky',
|
|
17
|
-
}
|
package/src/types/index.ts
DELETED
|
File without changes
|
|
File without changes
|