lupine.web 1.0.16 → 1.0.18

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.
Files changed (71) hide show
  1. package/package.json +1 -5
  2. package/src/core/bind-lang.ts +6 -5
  3. package/src/core/bind-links.ts +2 -2
  4. package/src/core/bind-styles.ts +6 -5
  5. package/src/core/bind-theme.ts +6 -5
  6. package/src/core/export-lupine.ts +64 -0
  7. package/src/core/index.ts +2 -1
  8. package/src/core/{core.ts → initialize.ts} +9 -67
  9. package/src/core/page-router.ts +3 -2
  10. package/src/core/server-cookie.ts +5 -3
  11. package/src/index.ts +0 -1
  12. package/src/lib/index.ts +2 -13
  13. package/src/lib/is-frontend.ts +3 -0
  14. package/src/styles/index.ts +0 -5
  15. package/src/components/button-push-animation.tsx +0 -138
  16. package/src/components/button.tsx +0 -55
  17. package/src/components/drag-refresh.tsx +0 -110
  18. package/src/components/editable-label.tsx +0 -83
  19. package/src/components/float-window.tsx +0 -226
  20. package/src/components/grid.tsx +0 -18
  21. package/src/components/html-var.tsx +0 -41
  22. package/src/components/index.ts +0 -36
  23. package/src/components/input-with-title.tsx +0 -24
  24. package/src/components/link-item.tsx +0 -13
  25. package/src/components/link-list.tsx +0 -62
  26. package/src/components/menu-bar.tsx +0 -220
  27. package/src/components/menu-item-props.tsx +0 -10
  28. package/src/components/menu-sidebar.tsx +0 -289
  29. package/src/components/message-box.tsx +0 -44
  30. package/src/components/meta-data.tsx +0 -36
  31. package/src/components/meta-description.tsx +0 -12
  32. package/src/components/modal.tsx +0 -29
  33. package/src/components/notice-message.tsx +0 -119
  34. package/src/components/page-title.tsx +0 -6
  35. package/src/components/paging-link.tsx +0 -100
  36. package/src/components/panel.tsx +0 -21
  37. package/src/components/popup-menu.tsx +0 -218
  38. package/src/components/progress.tsx +0 -91
  39. package/src/components/redirect.tsx +0 -19
  40. package/src/components/resizable-splitter.tsx +0 -129
  41. package/src/components/select-with-title.tsx +0 -37
  42. package/src/components/spinner.tsx +0 -100
  43. package/src/components/svg.tsx +0 -24
  44. package/src/components/tabs.tsx +0 -252
  45. package/src/components/text-glow.tsx +0 -36
  46. package/src/components/text-wave.tsx +0 -54
  47. package/src/components/theme-selector.tsx +0 -32
  48. package/src/components/toggle-base.tsx +0 -260
  49. package/src/components/toggle-switch.tsx +0 -156
  50. package/src/lib/date-utils.ts +0 -317
  51. package/src/lib/deep-merge.ts +0 -37
  52. package/src/lib/document-ready.ts +0 -36
  53. package/src/lib/dom/calculate-text-width.ts +0 -13
  54. package/src/lib/dom/download-stream.ts +0 -17
  55. package/src/lib/dom/download.ts +0 -12
  56. package/src/lib/dom/index.ts +0 -71
  57. package/src/lib/dynamical-load.ts +0 -138
  58. package/src/lib/format-bytes.ts +0 -11
  59. package/src/lib/lite-dom.ts +0 -227
  60. package/src/lib/message-hub.ts +0 -105
  61. package/src/lib/observable.ts +0 -188
  62. package/src/lib/promise-timeout.ts +0 -1
  63. package/src/lib/simple-storage.ts +0 -40
  64. package/src/lib/stop-propagation.ts +0 -7
  65. package/src/lib/upload-file.ts +0 -68
  66. package/src/styles/base-themes.ts +0 -17
  67. package/src/styles/dark-themes.ts +0 -86
  68. package/src/styles/light-themes.ts +0 -93
  69. package/src/styles/media-query.ts +0 -93
  70. package/src/styles/shared-themes.ts +0 -52
  71. /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.16",
3
+ "version": "1.0.18",
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",
@@ -1,4 +1,5 @@
1
- import { DomUtils } from '../lib';
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 (typeof window !== 'undefined') {
24
- DomUtils.setCookie(langCookieName, _langCfg.defaultLang);
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 (typeof window === 'undefined') {
35
+ if (!isFrontEnd()) {
35
36
  return;
36
37
  }
37
38
 
38
- DomUtils.setCookie(langCookieName, langName);
39
+ setCookie(langCookieName, langName);
39
40
  // document.documentElement.setAttribute(langAttributeName, langName);
40
41
 
41
42
  // // update lang for all iframe
@@ -1,4 +1,4 @@
1
- import { initializePage } from './core';
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
  }
@@ -159,10 +159,11 @@ if (typeof document !== 'undefined') {
159
159
  });
160
160
  }
161
161
 
162
- const clearGlobalStyles = () => {
163
- // reset unique id
164
- _globalStyle.clear();
165
- };
162
+ // 不能清空,在index.tsx中加载的只会被加载一次,清空了就没有了
163
+ // const clearGlobalStyles = () => {
164
+ // // reset unique id
165
+ // _globalStyle.clear();
166
+ // };
166
167
  // bindPageResetEvent(clearGlobalStyles);
167
168
 
168
169
  export const generateAllGlobalStyles = () => {
@@ -175,6 +176,6 @@ export const generateAllGlobalStyles = () => {
175
176
  result.push(`<style id="sty-${uniqueStyleId}">${cssText}</style>`);
176
177
  }
177
178
 
178
- clearGlobalStyles();
179
+ // clearGlobalStyles();
179
180
  return result.join('');
180
181
  };
@@ -1,5 +1,6 @@
1
- import { DomUtils } from '../lib';
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 (typeof window !== 'undefined') {
25
- DomUtils.setCookie(themeCookieName, _themeCfg.defaultTheme);
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 (typeof window === 'undefined') {
35
+ if (!isFrontEnd()) {
35
36
  return;
36
37
  }
37
38
 
38
- DomUtils.setCookie(themeCookieName, themeName);
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 './core';
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, JsonObject } from '../models';
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
- export type RenderPageFunctionsType = {
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
- export const generatePage = async (props: PageProps, toClientDelivery: IToClientDelivery): Promise<PageResultType> => {
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 (typeof window !== 'undefined') {
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;
@@ -1,7 +1,8 @@
1
1
  import { VNode } from '../jsx';
2
- import { Logger } from '../lib';
3
- import { isFrontEnd, PageProps } from './core';
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 { DomUtils } from '../lib';
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 (typeof window === 'undefined') {
7
+ if (!isFrontEnd()) {
7
8
  // SSR
8
9
  return getServerCookie(name);
9
10
  } else {
10
- return DomUtils.getCookie(name);
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
@@ -4,7 +4,6 @@ import { JSXInternal } from './jsx';
4
4
  export * from './jsx';
5
5
  export * from './core';
6
6
  export * from './lib';
7
- export * from './components';
8
7
  export * from './models';
9
8
  export * from './styles';
10
9
 
package/src/lib/index.ts CHANGED
@@ -1,17 +1,6 @@
1
- export * from './dom';
2
- export * from './date-utils';
1
+ export * from './cookie';
3
2
  export * from './debug-watch';
4
- export * from './deep-merge';
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';
@@ -0,0 +1,3 @@
1
+ export const isFrontEnd = () => {
2
+ return typeof window === 'object' && typeof document === 'object';
3
+ };
@@ -2,8 +2,3 @@ import { CssProps } from '../jsx';
2
2
  export { CssProps as CSS };
3
3
 
4
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,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
- };