lupine.web 1.0.16 → 1.0.17
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/package.json +1 -5
- package/src/core/bind-lang.ts +6 -5
- package/src/core/bind-links.ts +2 -2
- package/src/core/bind-theme.ts +6 -5
- package/src/core/export-lupine.ts +64 -0
- package/src/core/index.ts +2 -1
- package/src/core/{core.ts → initialize.ts} +9 -67
- package/src/core/page-router.ts +3 -2
- package/src/core/server-cookie.ts +5 -3
- package/src/index.ts +0 -1
- package/src/lib/index.ts +2 -13
- package/src/lib/is-frontend.ts +3 -0
- package/src/styles/index.ts +0 -5
- package/src/components/button-push-animation.tsx +0 -138
- package/src/components/button.tsx +0 -55
- package/src/components/drag-refresh.tsx +0 -110
- package/src/components/editable-label.tsx +0 -83
- package/src/components/float-window.tsx +0 -226
- package/src/components/grid.tsx +0 -18
- package/src/components/html-var.tsx +0 -41
- package/src/components/index.ts +0 -36
- package/src/components/input-with-title.tsx +0 -24
- package/src/components/link-item.tsx +0 -13
- package/src/components/link-list.tsx +0 -62
- package/src/components/menu-bar.tsx +0 -220
- package/src/components/menu-item-props.tsx +0 -10
- package/src/components/menu-sidebar.tsx +0 -289
- package/src/components/message-box.tsx +0 -44
- package/src/components/meta-data.tsx +0 -36
- package/src/components/meta-description.tsx +0 -12
- package/src/components/modal.tsx +0 -29
- package/src/components/notice-message.tsx +0 -119
- package/src/components/page-title.tsx +0 -6
- package/src/components/paging-link.tsx +0 -100
- package/src/components/panel.tsx +0 -21
- package/src/components/popup-menu.tsx +0 -218
- package/src/components/progress.tsx +0 -91
- package/src/components/redirect.tsx +0 -19
- package/src/components/resizable-splitter.tsx +0 -129
- package/src/components/select-with-title.tsx +0 -37
- package/src/components/spinner.tsx +0 -100
- package/src/components/svg.tsx +0 -24
- package/src/components/tabs.tsx +0 -252
- package/src/components/text-glow.tsx +0 -36
- package/src/components/text-wave.tsx +0 -54
- package/src/components/theme-selector.tsx +0 -32
- package/src/components/toggle-base.tsx +0 -260
- package/src/components/toggle-switch.tsx +0 -156
- package/src/lib/date-utils.ts +0 -317
- package/src/lib/deep-merge.ts +0 -37
- package/src/lib/document-ready.ts +0 -36
- package/src/lib/dom/calculate-text-width.ts +0 -13
- package/src/lib/dom/download-stream.ts +0 -17
- package/src/lib/dom/download.ts +0 -12
- package/src/lib/dom/index.ts +0 -71
- package/src/lib/dynamical-load.ts +0 -138
- package/src/lib/format-bytes.ts +0 -11
- package/src/lib/lite-dom.ts +0 -227
- package/src/lib/message-hub.ts +0 -105
- package/src/lib/observable.ts +0 -188
- package/src/lib/promise-timeout.ts +0 -1
- package/src/lib/simple-storage.ts +0 -40
- package/src/lib/stop-propagation.ts +0 -7
- package/src/lib/upload-file.ts +0 -68
- package/src/styles/base-themes.ts +0 -17
- package/src/styles/dark-themes.ts +0 -86
- package/src/styles/light-themes.ts +0 -93
- package/src/styles/media-query.ts +0 -93
- package/src/styles/shared-themes.ts +0 -52
- /package/src/lib/{dom/cookie.ts → cookie.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lupine.web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "uuware.com",
|
|
6
6
|
"homepage": "https://uuware.com/",
|
|
7
7
|
"description": "lupine.web is a extremely fast, small size and lightweight frontend framework, using React TSX syntax.",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/uuware/lupine.web.git"
|
|
11
|
-
},
|
|
12
8
|
"main": "src/index.ts",
|
|
13
9
|
"source": "src/index.ts",
|
|
14
10
|
"types": "src/index.ts",
|
package/src/core/bind-lang.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setCookie } from '../lib/cookie';
|
|
2
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
2
3
|
import { getEitherCookie } from './server-cookie';
|
|
3
4
|
|
|
4
5
|
// The FE only loads one language for the consideration of the size
|
|
@@ -20,8 +21,8 @@ export const getCurrentLang = () => {
|
|
|
20
21
|
let langName = getEitherCookie(langCookieName) as string;
|
|
21
22
|
if (!langName || !_langCfg.langs[langName]) {
|
|
22
23
|
langName = _langCfg.defaultLang;
|
|
23
|
-
if (
|
|
24
|
-
|
|
24
|
+
if (isFrontEnd()) {
|
|
25
|
+
setCookie(langCookieName, _langCfg.defaultLang);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
return { langName, langs: _langCfg.langs };
|
|
@@ -31,11 +32,11 @@ export const getCurrentLang = () => {
|
|
|
31
32
|
export const updateLang = (langName: string) => {
|
|
32
33
|
// Lang is only updated in Browser
|
|
33
34
|
_langCfg.defaultLang = langName;
|
|
34
|
-
if (
|
|
35
|
+
if (!isFrontEnd()) {
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
setCookie(langCookieName, langName);
|
|
39
40
|
// document.documentElement.setAttribute(langAttributeName, langName);
|
|
40
41
|
|
|
41
42
|
// // update lang for all iframe
|
package/src/core/bind-links.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _lupineJs } from './export-lupine';
|
|
2
2
|
|
|
3
3
|
export function bindLinks(el: Element | Document) {
|
|
4
4
|
const links = el.getElementsByTagName('a');
|
|
@@ -8,7 +8,7 @@ export function bindLinks(el: Element | Document) {
|
|
|
8
8
|
href = href.substring(document.location.origin.length);
|
|
9
9
|
// console.log(`====${href}, javascript:init('${document.links[i].href}')`);
|
|
10
10
|
links[i].onclick = () => {
|
|
11
|
-
initializePage(href);
|
|
11
|
+
_lupineJs.initializePage(href);
|
|
12
12
|
return false;
|
|
13
13
|
};
|
|
14
14
|
}
|
package/src/core/bind-theme.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setCookie } from '../lib/cookie';
|
|
2
2
|
import { ThemesProps } from '../models';
|
|
3
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
3
4
|
import { getEitherCookie } from './server-cookie';
|
|
4
5
|
|
|
5
6
|
// theme doesn't need to reset, theme name is stored in cookie
|
|
@@ -21,8 +22,8 @@ export const getCurrentTheme = () => {
|
|
|
21
22
|
let themeName = getEitherCookie(themeCookieName) as string;
|
|
22
23
|
if (!themeName || !_themeCfg.themes[themeName]) {
|
|
23
24
|
themeName = _themeCfg.defaultTheme;
|
|
24
|
-
if (
|
|
25
|
-
|
|
25
|
+
if (isFrontEnd()) {
|
|
26
|
+
setCookie(themeCookieName, _themeCfg.defaultTheme);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
return { themeName, themes: _themeCfg.themes };
|
|
@@ -31,11 +32,11 @@ export const getCurrentTheme = () => {
|
|
|
31
32
|
export const updateTheme = (themeName: string) => {
|
|
32
33
|
// Theme is only updated in Browser
|
|
33
34
|
_themeCfg.defaultTheme = themeName;
|
|
34
|
-
if (
|
|
35
|
+
if (!isFrontEnd()) {
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
setCookie(themeCookieName, themeName);
|
|
39
40
|
document.documentElement.setAttribute(themeAttributeName, themeName);
|
|
40
41
|
|
|
41
42
|
// update theme for all iframe
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { VNode } from '../jsx';
|
|
2
|
+
import { PageRouter } from './page-router';
|
|
3
|
+
import { IToClientDelivery, JsonObject } from '../models';
|
|
4
|
+
|
|
5
|
+
export type RenderPageFunctionsType = {
|
|
6
|
+
fetchData: (url: string, postBody?: string | JsonObject, returnRawResponse?: boolean) => Promise<any>;
|
|
7
|
+
[key: string]: Function;
|
|
8
|
+
};
|
|
9
|
+
export interface PageProps {
|
|
10
|
+
url: string;
|
|
11
|
+
// urlSections: string[];
|
|
12
|
+
query: { [key: string]: string };
|
|
13
|
+
urlParameters: { [key: string]: string };
|
|
14
|
+
renderPageFunctions: RenderPageFunctionsType;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type PageResultType = {
|
|
18
|
+
content: string;
|
|
19
|
+
title: string;
|
|
20
|
+
metaData: string;
|
|
21
|
+
themeName: string;
|
|
22
|
+
globalCss: string;
|
|
23
|
+
};
|
|
24
|
+
export type _LupineJs = {
|
|
25
|
+
// generatePage and initializePage are set in initialize.ts to avoid circular reference
|
|
26
|
+
generatePage: (props: any, toClientDelivery: IToClientDelivery) => Promise<PageResultType>;
|
|
27
|
+
initializePage: (newUrl?: string) => Promise<void>;
|
|
28
|
+
renderPageFunctions: RenderPageFunctionsType;
|
|
29
|
+
router: PageRouter | ((props: PageProps) => Promise<VNode<any>>);
|
|
30
|
+
renderPageProps: PageProps;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// main instance to be used in the FE and the BE
|
|
34
|
+
export const _lupineJs: _LupineJs = {} as _LupineJs;
|
|
35
|
+
|
|
36
|
+
// for SSR, it exports _lupineJs function for the server to call
|
|
37
|
+
if (typeof exports !== 'undefined') {
|
|
38
|
+
// ignore esbuild's warnings:
|
|
39
|
+
// The CommonJS "exports" variable is treated as a global variable in an ECMAScript module and may not work as expected [commonjs-variable-in-esm]
|
|
40
|
+
exports._lupineJs = () => {
|
|
41
|
+
return _lupineJs;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// this should be called by the FE and also by the server side to set fetchData and others for client and server side rendering.
|
|
46
|
+
// And the RenderPageFunctionsType will be passed to call (generate) a page through PageProps
|
|
47
|
+
export const bindRenderPageFunctions = (calls: RenderPageFunctionsType) => {
|
|
48
|
+
_lupineJs.renderPageFunctions = calls || {};
|
|
49
|
+
};
|
|
50
|
+
// export const getRenderPageFunctions = (): RenderPageFunctionsType => {
|
|
51
|
+
// return globalThis._lupineJs.renderPageFunctions;
|
|
52
|
+
// }
|
|
53
|
+
// this is only used inside the core
|
|
54
|
+
export const setRenderPageProps = (props: PageProps) => {
|
|
55
|
+
_lupineJs.renderPageProps = props;
|
|
56
|
+
};
|
|
57
|
+
// this is used by the code to get url info when it's executed in the FE or in the server side.
|
|
58
|
+
export const getRenderPageProps = (): PageProps => {
|
|
59
|
+
return _lupineJs.renderPageProps;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const bindRouter = (router: PageRouter | ((props: PageProps) => Promise<VNode<any>>)) => {
|
|
63
|
+
_lupineJs.router = router;
|
|
64
|
+
};
|
package/src/core/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './bind-meta';
|
|
|
5
5
|
export * from './bind-ref';
|
|
6
6
|
export * from './bind-styles';
|
|
7
7
|
export * from './bind-theme';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './export-lupine';
|
|
9
9
|
export * from './camel-to-hyphens';
|
|
10
10
|
export * from './mount-components';
|
|
11
11
|
export * from './page-loaded-events';
|
|
@@ -14,3 +14,4 @@ export * from './replace-innerhtml';
|
|
|
14
14
|
export * from './server-cookie';
|
|
15
15
|
export * from './web-version';
|
|
16
16
|
|
|
17
|
+
export * from './initialize';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { VNode } from '../jsx';
|
|
2
|
-
import { initWebEnv, initWebSetting } from '../lib';
|
|
3
1
|
import { Logger } from '../lib/logger';
|
|
4
2
|
import { generateAllGlobalStyles } from './bind-styles';
|
|
5
3
|
import { defaultThemeName, getCurrentTheme, updateTheme } from './bind-theme';
|
|
@@ -8,71 +6,13 @@ import { mountComponents } from './mount-components';
|
|
|
8
6
|
import { PageRouter } from './page-router';
|
|
9
7
|
import { callPageLoadedEvent } from './page-loaded-events';
|
|
10
8
|
import { initServerCookies } from './server-cookie';
|
|
11
|
-
import { IToClientDelivery
|
|
9
|
+
import { IToClientDelivery } from '../models';
|
|
12
10
|
import { getMetaDataObject, getMetaDataTags, getPageTitle } from './bind-meta';
|
|
11
|
+
import { initWebEnv, initWebSetting } from '../lib/web-env';
|
|
12
|
+
import { _lupineJs, PageProps, PageResultType, setRenderPageProps } from './export-lupine';
|
|
13
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
fetchData: (url: string, postBody?: string | JsonObject, returnRawResponse?: boolean) => Promise<any>;
|
|
16
|
-
[key: string]: Function;
|
|
17
|
-
};
|
|
18
|
-
export interface PageProps {
|
|
19
|
-
url: string;
|
|
20
|
-
// urlSections: string[];
|
|
21
|
-
query: { [key: string]: string };
|
|
22
|
-
urlParameters: { [key: string]: string };
|
|
23
|
-
renderPageFunctions: RenderPageFunctionsType;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type PageResultType = {
|
|
27
|
-
content: string;
|
|
28
|
-
title: string;
|
|
29
|
-
metaData: string;
|
|
30
|
-
themeName: string;
|
|
31
|
-
globalCss: string;
|
|
32
|
-
};
|
|
33
|
-
export type _LupineJs = {
|
|
34
|
-
generatePage: (props: any, toClientDelivery: IToClientDelivery) => Promise<PageResultType>;
|
|
35
|
-
renderPageFunctions: RenderPageFunctionsType;
|
|
36
|
-
router: PageRouter | ((props: PageProps) => Promise<VNode<any>>);
|
|
37
|
-
renderPageProps: PageProps;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const logger = new Logger('core');
|
|
41
|
-
export const _lupineJs: _LupineJs = {} as _LupineJs;
|
|
42
|
-
|
|
43
|
-
// for SSR, it exports _lupineJs function for the server to call
|
|
44
|
-
if (typeof exports !== 'undefined') {
|
|
45
|
-
// ignore esbuild's warnings:
|
|
46
|
-
// The CommonJS "exports" variable is treated as a global variable in an ECMAScript module and may not work as expected [commonjs-variable-in-esm]
|
|
47
|
-
exports._lupineJs = () => {
|
|
48
|
-
return _lupineJs;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// this should be called by the FE and also by the server side to set fetchData and others for client and server side rendering.
|
|
53
|
-
// And the RenderPageFunctionsType will be passed to call (generate) a page through PageProps
|
|
54
|
-
export const bindRenderPageFunctions = (calls: RenderPageFunctionsType) => {
|
|
55
|
-
_lupineJs.renderPageFunctions = calls || {};
|
|
56
|
-
};
|
|
57
|
-
// export const getRenderPageFunctions = (): RenderPageFunctionsType => {
|
|
58
|
-
// return globalThis._lupineJs.renderPageFunctions;
|
|
59
|
-
// }
|
|
60
|
-
// this is only used inside the core
|
|
61
|
-
const setRenderPageProps = (props: PageProps) => {
|
|
62
|
-
_lupineJs.renderPageProps = props;
|
|
63
|
-
};
|
|
64
|
-
// this is used by the code to get url info when it's executed in the FE or in the server side.
|
|
65
|
-
export const getRenderPageProps = (): PageProps => {
|
|
66
|
-
return _lupineJs.renderPageProps;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const bindRouter = (router: PageRouter | ((props: PageProps) => Promise<VNode<any>>)) => {
|
|
70
|
-
_lupineJs.router = router;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const isFrontEnd = () => {
|
|
74
|
-
return typeof window === 'object' && typeof document === 'object';
|
|
75
|
-
};
|
|
15
|
+
const logger = new Logger('initialize');
|
|
76
16
|
|
|
77
17
|
const renderTargetPage = async (props: PageProps, renderPartPage: boolean) => {
|
|
78
18
|
if (_lupineJs.router instanceof PageRouter) {
|
|
@@ -82,7 +22,7 @@ const renderTargetPage = async (props: PageProps, renderPartPage: boolean) => {
|
|
|
82
22
|
};
|
|
83
23
|
|
|
84
24
|
// this is called by server side for SSR (server-side-rendering)
|
|
85
|
-
|
|
25
|
+
const generatePage = async (props: PageProps, toClientDelivery: IToClientDelivery): Promise<PageResultType> => {
|
|
86
26
|
setRenderPageProps(props);
|
|
87
27
|
|
|
88
28
|
initWebEnv(toClientDelivery.getWebEnv());
|
|
@@ -119,6 +59,7 @@ _lupineJs.generatePage = generatePage;
|
|
|
119
59
|
|
|
120
60
|
let _pageInitialized = false;
|
|
121
61
|
// this is called in the FE when the document is loaded
|
|
62
|
+
// to avoid circular reference, bindLinks can't call initializePage directly
|
|
122
63
|
export const initializePage = async (newUrl?: string) => {
|
|
123
64
|
const currentPageInitialized = _pageInitialized;
|
|
124
65
|
_pageInitialized = true;
|
|
@@ -160,7 +101,7 @@ export const initializePage = async (newUrl?: string) => {
|
|
|
160
101
|
const metaData = getMetaDataObject();
|
|
161
102
|
// meta data?
|
|
162
103
|
};
|
|
163
|
-
if (
|
|
104
|
+
if (isFrontEnd()) {
|
|
164
105
|
addEventListener('popstate', (event) => {
|
|
165
106
|
initializePage();
|
|
166
107
|
});
|
|
@@ -168,3 +109,4 @@ if (typeof window !== 'undefined') {
|
|
|
168
109
|
initializePage();
|
|
169
110
|
});
|
|
170
111
|
}
|
|
112
|
+
_lupineJs.initializePage = initializePage;
|
package/src/core/page-router.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { VNode } from '../jsx';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
3
|
+
import { PageProps } from './export-lupine';
|
|
4
4
|
import { mountComponents } from './mount-components';
|
|
5
|
+
import { Logger } from '../lib/logger';
|
|
5
6
|
|
|
6
7
|
export type PageRouterCallback = (props: PageProps) => Promise<VNode<any> | null>;
|
|
7
8
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCookie } from '../lib/cookie';
|
|
2
2
|
import { ISimpleStorage } from '../models/simple-storage-props';
|
|
3
|
+
import { isFrontEnd } from '../lib/is-frontend';
|
|
3
4
|
|
|
4
5
|
// getEitherCookie can be used in both FE and SSR
|
|
5
6
|
export const getEitherCookie = (name: string) => {
|
|
6
|
-
if (
|
|
7
|
+
if (!isFrontEnd()) {
|
|
7
8
|
// SSR
|
|
8
9
|
return getServerCookie(name);
|
|
9
10
|
} else {
|
|
10
|
-
return
|
|
11
|
+
return getCookie(name);
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -17,6 +18,7 @@ export const getServerCookie = (name: string) => {
|
|
|
17
18
|
return _serverCookies && _serverCookies.get(name, '');
|
|
18
19
|
};
|
|
19
20
|
// TODO: Server cookies safety should be OK? as this is dropped after SSR
|
|
21
|
+
// This is called by server side to initialize cookies for SSR
|
|
20
22
|
export const initServerCookies = (serverCookies: ISimpleStorage) => {
|
|
21
23
|
return (_serverCookies = serverCookies);
|
|
22
24
|
};
|
package/src/index.ts
CHANGED
package/src/lib/index.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './date-utils';
|
|
1
|
+
export * from './cookie';
|
|
3
2
|
export * from './debug-watch';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './document-ready';
|
|
6
|
-
export * from './dynamical-load';
|
|
7
|
-
export * from './format-bytes';
|
|
8
|
-
export * from './lite-dom';
|
|
3
|
+
export * from './is-frontend';
|
|
9
4
|
export * from './logger';
|
|
10
|
-
export * from './message-hub';
|
|
11
|
-
export * from './observable';
|
|
12
|
-
export * from './promise-timeout';
|
|
13
|
-
export * from './simple-storage';
|
|
14
|
-
export * from './stop-propagation';
|
|
15
5
|
export * from './unique-id';
|
|
16
|
-
export * from './upload-file';
|
|
17
6
|
export * from './web-env';
|
package/src/styles/index.ts
CHANGED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { CssProps, RefProps } from 'lupine.web';
|
|
2
|
-
|
|
3
|
-
export enum ButtonPushAnimationSize {
|
|
4
|
-
SmallSmall = 'button-ss',
|
|
5
|
-
Small = 'button-s',
|
|
6
|
-
Medium = 'button-m',
|
|
7
|
-
Large = 'button-l',
|
|
8
|
-
LargeLarge = 'button-ll',
|
|
9
|
-
}
|
|
10
|
-
export type ButtonPushAnimationHookProps = {
|
|
11
|
-
setEnabled?: (enabled: boolean) => void;
|
|
12
|
-
getEnabled?: () => boolean;
|
|
13
|
-
};
|
|
14
|
-
export type ButtonPushAnimationProps = {
|
|
15
|
-
text: string;
|
|
16
|
-
size: ButtonPushAnimationSize;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
onClick?: () => void;
|
|
19
|
-
hook?: ButtonPushAnimationHookProps;
|
|
20
|
-
class?: string;
|
|
21
|
-
css?: CssProps;
|
|
22
|
-
};
|
|
23
|
-
export const ButtonPushAnimation = (props: ButtonPushAnimationProps) => {
|
|
24
|
-
let disabled = props.disabled || false;
|
|
25
|
-
const onClick = () => {
|
|
26
|
-
if (disabled) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (props.onClick) {
|
|
30
|
-
props.onClick();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
if (props.hook) {
|
|
34
|
-
props.hook.setEnabled = (enabled: boolean) => {
|
|
35
|
-
disabled = !enabled;
|
|
36
|
-
ref.current.disabled = disabled;
|
|
37
|
-
};
|
|
38
|
-
props.hook.getEnabled = () => {
|
|
39
|
-
return !disabled;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const ref: RefProps = {};
|
|
44
|
-
const css: CssProps = {
|
|
45
|
-
all: 'unset',
|
|
46
|
-
cursor: 'pointer',
|
|
47
|
-
'-webkit-tap-highlight-color': 'rgba(0, 0, 0, 0)',
|
|
48
|
-
position: 'relative',
|
|
49
|
-
borderRadius: 'var(--border-radius-m)',
|
|
50
|
-
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
|
51
|
-
boxShadow: '-0.15em -0.15em 0.15em -0.075em rgba(5, 5, 5, 0.25), 0.0375em 0.0375em 0.0675em 0 rgba(5, 5, 5, 0.1)',
|
|
52
|
-
'.button-outer': {
|
|
53
|
-
position: 'relative',
|
|
54
|
-
zIndex: 1,
|
|
55
|
-
borderRadius: 'inherit',
|
|
56
|
-
transition: 'box-shadow 300ms ease',
|
|
57
|
-
willChange: 'box-shadow',
|
|
58
|
-
boxShadow: '0 0.05em 0.05em -0.01em rgba(5, 5, 5, 1), 0 0.01em 0.01em -0.01em rgba(5, 5, 5, 0.5), 0.15em 0.3em 0.1em -0.01em rgba(5, 5, 5, 0.25)',
|
|
59
|
-
},
|
|
60
|
-
'.button-inner': {
|
|
61
|
-
position: 'relative',
|
|
62
|
-
zIndex: 2,
|
|
63
|
-
borderRadius: 'inherit',
|
|
64
|
-
padding: 'var(--button-padding)',
|
|
65
|
-
background: 'linear-gradient(135deg, #ffffff, #eeeeee)',
|
|
66
|
-
transition: 'box-shadow 300ms ease, background-image 250ms ease, transform 250ms ease;',
|
|
67
|
-
willChange: 'box-shadow, background-image, transform',
|
|
68
|
-
overflow: 'clip',
|
|
69
|
-
// clipPath: 'inset(0 0 0 0 round 999vw)',
|
|
70
|
-
boxShadow: '0 0 0 0 inset rgba(5, 5, 5, 0.1), -0.05em -0.05em 0.05em 0 inset rgba(5, 5, 5, 0.25), 0 0 0 0 inset rgba(5, 5, 5, 0.1), 0 0 0.05em 0.2em inset rgba(255, 255, 255, 0.25), 0.025em 0.05em 0.1em 0 inset rgba(255, 255, 255, 1), 0.12em 0.12em 0.12em inset rgba(255, 255, 255, 0.25), -0.075em -0.25em 0.25em 0.1em inset rgba(5, 5, 5, 0.25)',
|
|
71
|
-
},
|
|
72
|
-
'.button-inner span': {
|
|
73
|
-
position: 'relative',
|
|
74
|
-
zIndex: 4,
|
|
75
|
-
// fontFamily: 'Inter, sans-serif',
|
|
76
|
-
letterSpacing: '-0.05em',
|
|
77
|
-
// fontWeight: 500,
|
|
78
|
-
color: 'rgba(0, 0, 0, 0);',
|
|
79
|
-
backgroundImage: 'linear-gradient(135deg, rgba(25, 25, 25, 1), rgba(75, 75, 75, 1))',
|
|
80
|
-
backgroundClip: 'text',
|
|
81
|
-
transition: 'transform 250ms ease',
|
|
82
|
-
display: 'block',
|
|
83
|
-
willChange: 'transform',
|
|
84
|
-
textShadow: 'rgba(0, 0, 0, 0.1) 0 0 0.1em',
|
|
85
|
-
userSelect: 'none',
|
|
86
|
-
},
|
|
87
|
-
'&.button-ss': {
|
|
88
|
-
borderRadius: '2px',
|
|
89
|
-
},
|
|
90
|
-
'&.button-s': {
|
|
91
|
-
borderRadius: '3px',
|
|
92
|
-
},
|
|
93
|
-
'&.button-l': {
|
|
94
|
-
borderRadius: '6px',
|
|
95
|
-
},
|
|
96
|
-
'&.button-ll': {
|
|
97
|
-
borderRadius: '10px',
|
|
98
|
-
},
|
|
99
|
-
'&.button-ss .button-inner': {
|
|
100
|
-
padding: '0.1rem 0.3rem',
|
|
101
|
-
fontSize: '0.65rem',
|
|
102
|
-
},
|
|
103
|
-
'&.button-s .button-inner': {
|
|
104
|
-
padding: '0.2rem 0.5rem',
|
|
105
|
-
fontSize: '0.85rem',
|
|
106
|
-
},
|
|
107
|
-
'&.button-l .button-inner': {
|
|
108
|
-
padding: '0.4rem 1.2rem',
|
|
109
|
-
fontSize: '1.5rem',
|
|
110
|
-
},
|
|
111
|
-
'&.button-ll .button-inner': {
|
|
112
|
-
padding: '0.5rem 1.5rem',
|
|
113
|
-
fontSize: '2rem',
|
|
114
|
-
},
|
|
115
|
-
'&:active .button-outer': {
|
|
116
|
-
boxShadow: '0 0 0 0 rgba(5, 5, 5, 1), 0 0 0 0 rgba(5, 5, 5, 0.5), 0 0 0 0 rgba(5, 5, 5, 0.25)',
|
|
117
|
-
},
|
|
118
|
-
'&:active .button-inner': {
|
|
119
|
-
boxShadow: '0.1em 0.15em 0.05em 0 inset rgba(5, 5, 5, 0.75), -0.025em -0.03em 0.05em 0.025em inset rgba(5, 5, 5, 0.5), 0.25em 0.25em 0.2em 0 inset rgba(5, 5, 5, 0.5), 0 0 0.05em 0.5em inset rgba(255, 255, 255, 0.15), 0 0 0 0 inset rgba(255, 255, 255, 1), 0.12em 0.12em 0.12em inset rgba(255, 255, 255, 0.25), -0.075em -0.12em 0.2em 0.1em inset rgba(5, 5, 5, 0.25)',
|
|
120
|
-
},
|
|
121
|
-
'&:hover .button-inner': {
|
|
122
|
-
transform: 'scale(0.99)',
|
|
123
|
-
},
|
|
124
|
-
'&:hover .button-inner span': {
|
|
125
|
-
transform: 'scale(0.975)',
|
|
126
|
-
},
|
|
127
|
-
...props.css,
|
|
128
|
-
};
|
|
129
|
-
return (
|
|
130
|
-
<button ref={ref} css={css} class={['button-push-animation', props.size, props.class].join(' ')} disabled={disabled} onClick={onClick}>
|
|
131
|
-
<div class="button-outer">
|
|
132
|
-
<div class="button-inner">
|
|
133
|
-
<span>{props.text}</span>
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
136
|
-
</button>
|
|
137
|
-
);
|
|
138
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { CssProps, RefProps } from 'lupine.web';
|
|
2
|
-
|
|
3
|
-
export enum ButtonSize {
|
|
4
|
-
SmallLarge = 'button-ss',
|
|
5
|
-
Small = 'button-s',
|
|
6
|
-
Medium = 'button-m',
|
|
7
|
-
Large = 'button-l',
|
|
8
|
-
LargeLarge = 'button-ll',
|
|
9
|
-
}
|
|
10
|
-
export type ButtonHookProps = {
|
|
11
|
-
setEnabled?: (enabled: boolean) => void;
|
|
12
|
-
getEnabled?: () => boolean;
|
|
13
|
-
};
|
|
14
|
-
export type ButtonProps = {
|
|
15
|
-
text: string;
|
|
16
|
-
size: ButtonSize;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
onClick?: () => void;
|
|
19
|
-
hook?: ButtonHookProps;
|
|
20
|
-
class?: string;
|
|
21
|
-
css?: CssProps;
|
|
22
|
-
};
|
|
23
|
-
export const Button = (props: ButtonProps) => {
|
|
24
|
-
let disabled = props.disabled || false;
|
|
25
|
-
const onClick = () => {
|
|
26
|
-
if (disabled) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (props.onClick) {
|
|
30
|
-
props.onClick();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
if (props.hook) {
|
|
34
|
-
props.hook.setEnabled = (enabled: boolean) => {
|
|
35
|
-
disabled = !enabled;
|
|
36
|
-
ref.current.disabled = disabled;
|
|
37
|
-
};
|
|
38
|
-
props.hook.getEnabled = () => {
|
|
39
|
-
return !disabled;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const ref: RefProps = {};
|
|
44
|
-
return (
|
|
45
|
-
<button
|
|
46
|
-
ref={ref}
|
|
47
|
-
class={['button-base', props.size, props.class].join(' ')}
|
|
48
|
-
css={props.css}
|
|
49
|
-
disabled={disabled}
|
|
50
|
-
onClick={onClick}
|
|
51
|
-
>
|
|
52
|
-
{props.text}
|
|
53
|
-
</button>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { CssProps, RefProps } from '../jsx';
|
|
2
|
-
import { Spinner02, SpinnerSize } from './spinner';
|
|
3
|
-
|
|
4
|
-
export type DragRefreshCloseProps = () => void;
|
|
5
|
-
|
|
6
|
-
export type DragRefreshProps = {
|
|
7
|
-
container: string;
|
|
8
|
-
onDragRefresh: (close: DragRefreshCloseProps) => Promise<void>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const DragFresh = (props: DragRefreshProps) => {
|
|
12
|
-
const css: CssProps = {
|
|
13
|
-
display: 'flex',
|
|
14
|
-
flexDirection: 'column',
|
|
15
|
-
width: '100%',
|
|
16
|
-
height: '0px',
|
|
17
|
-
position: 'relative',
|
|
18
|
-
'.drag-spinner': {
|
|
19
|
-
position: 'fixed',
|
|
20
|
-
top: '0',
|
|
21
|
-
left: '0',
|
|
22
|
-
width: '100%',
|
|
23
|
-
zIndex: 3,
|
|
24
|
-
display: 'none',
|
|
25
|
-
justifyContent: 'center',
|
|
26
|
-
transition: 'opacity 0.5s ease',
|
|
27
|
-
alignItems: 'end',
|
|
28
|
-
backgroundImage: 'linear-gradient(to bottom, rgba(200,200,200,0.8), rgba(255,255,255,0))',
|
|
29
|
-
},
|
|
30
|
-
'&.show .drag-spinner': {
|
|
31
|
-
display: 'flex',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const closeSpin = () => {
|
|
36
|
-
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
37
|
-
if (!spinnerDom) return;
|
|
38
|
-
spinnerDom.style.opacity = '0';
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
spinnerDom.style.opacity = '1';
|
|
41
|
-
spinnerDom.parentElement!.classList.remove('show');
|
|
42
|
-
}, 300);
|
|
43
|
-
};
|
|
44
|
-
const ref: RefProps = {
|
|
45
|
-
onLoad: async () => {
|
|
46
|
-
const container = document.querySelector(props.container) as HTMLDivElement;
|
|
47
|
-
const pullDom = ref.current as HTMLDivElement;
|
|
48
|
-
const spinnerDom = ref.$('.drag-spinner') as HTMLDivElement;
|
|
49
|
-
if (!container || !pullDom || !spinnerDom) return;
|
|
50
|
-
let touchstartY = 0;
|
|
51
|
-
let touchstartX = 0;
|
|
52
|
-
let direction = '';
|
|
53
|
-
let needRefresh = false;
|
|
54
|
-
const maxHeight = 150;
|
|
55
|
-
container.addEventListener('touchstart', (e: any) => {
|
|
56
|
-
touchstartY = e.touches[0].clientY;
|
|
57
|
-
touchstartX = e.touches[0].clientX;
|
|
58
|
-
direction = '';
|
|
59
|
-
needRefresh = false;
|
|
60
|
-
});
|
|
61
|
-
container.addEventListener('touchmove', (e: any) => {
|
|
62
|
-
console.log(`window.scrollY: ${window.scrollY}`);
|
|
63
|
-
const touchY = e.touches[0].clientY;
|
|
64
|
-
const touchX = e.touches[0].clientX;
|
|
65
|
-
const movedY = touchY - touchstartY;
|
|
66
|
-
const movedX = touchX - touchstartX;
|
|
67
|
-
if (direction === '') {
|
|
68
|
-
if (movedY > 0) {
|
|
69
|
-
direction = 'Y';
|
|
70
|
-
} else if (movedX > 0) {
|
|
71
|
-
direction = 'X';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (direction === 'X') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (window.scrollY === 0) {
|
|
78
|
-
needRefresh = movedY > 30;
|
|
79
|
-
if (movedY > 5) {
|
|
80
|
-
pullDom.classList.add('show');
|
|
81
|
-
spinnerDom.style.height = `${Math.min(maxHeight, movedY)}px`;
|
|
82
|
-
} else {
|
|
83
|
-
pullDom.classList.remove('show');
|
|
84
|
-
spinnerDom.style.height = '0';
|
|
85
|
-
}
|
|
86
|
-
} else if (window.scrollY > Math.min(maxHeight, movedY)) {
|
|
87
|
-
pullDom.classList.remove('show');
|
|
88
|
-
spinnerDom.style.height = '0';
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
container.addEventListener('touchend', (e) => {
|
|
92
|
-
if (direction === 'Y') {
|
|
93
|
-
if (needRefresh) {
|
|
94
|
-
props.onDragRefresh(closeSpin);
|
|
95
|
-
} else {
|
|
96
|
-
closeSpin();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
direction = '';
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
return (
|
|
104
|
-
<div css={css} ref={ref} class='drag-refresh-box'>
|
|
105
|
-
<div class='drag-spinner'>
|
|
106
|
-
<Spinner02 size={SpinnerSize.Large} />
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
};
|