@xyd-js/ui 0.1.0-xyd.5 → 0.1.0-xyd.6

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/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./src/components"
2
-
3
- export * from "./src/types"
package/rollup.config.js DELETED
@@ -1,81 +0,0 @@
1
- import resolve from '@rollup/plugin-node-resolve';
2
- import commonjs from '@rollup/plugin-commonjs';
3
- import typescript from '@rollup/plugin-typescript';
4
- import dts from 'rollup-plugin-dts';
5
- import {terser} from 'rollup-plugin-terser';
6
- import babel from '@rollup/plugin-babel';
7
- import postcss from 'rollup-plugin-postcss';
8
- import wyw from '@wyw-in-js/rollup';
9
-
10
- import {createRequire} from 'module';
11
-
12
- const require = createRequire(import.meta.url);
13
- const {
14
- dependencies,
15
- peerDependencies,
16
- devDependencies
17
- } = require('./package.json', {assert: {type: 'json'}});
18
-
19
- const external = [
20
- ...Object.keys(dependencies),
21
- ...Object.keys(peerDependencies),
22
- ...Object.keys(devDependencies),
23
- ];
24
-
25
- export default [
26
- {
27
- input: {
28
- index: 'index.ts'
29
- },
30
- output: [
31
- {
32
- dir: 'dist',
33
- format: 'esm',
34
- sourcemap: true,
35
- entryFileNames: '[name].js'
36
- }
37
- ],
38
- plugins: [
39
- wyw({
40
- include: ['**/*.{ts,tsx}'],
41
- babelOptions: {
42
- presets: [
43
- '@babel/preset-typescript',
44
- '@babel/preset-react'
45
- ],
46
- },
47
- }),
48
- postcss({
49
- extract: true,
50
- plugins: [
51
- require('postcss-import'),
52
- require('autoprefixer')
53
- ]
54
- }),
55
- resolve(),
56
- commonjs(),
57
- typescript({
58
- tsconfig: './tsconfig.json',
59
- }),
60
- babel({
61
- babelHelpers: 'bundled',
62
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
63
- presets: [
64
- '@babel/preset-env',
65
- '@babel/preset-react'
66
- ],
67
- }),
68
- terser(),
69
- ],
70
- external
71
- },
72
- {
73
- input: 'index.ts',
74
- output: {
75
- file: 'dist/index.d.ts',
76
- format: 'es',
77
- },
78
- plugins: [dts()],
79
- external
80
- }
81
- ];
@@ -1,7 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const $anchor = {
4
- host: css`
5
-
6
- `,
7
- };
@@ -1,57 +0,0 @@
1
- import React, {forwardRef} from 'react'
2
- import type {ComponentProps, ReactElement} from 'react'
3
-
4
- import {$anchor} from "./Anchor.styles";
5
-
6
- export type UIAnchorProps = Omit<ComponentProps<'a'>, 'ref'> & {
7
- newWindow?: boolean
8
- }
9
-
10
- function Link(props: any) {
11
- return <div>Link</div>
12
- }
13
-
14
- export const UIAnchor = forwardRef<HTMLAnchorElement, UIAnchorProps>(function (
15
- {href = '', children, newWindow},
16
- // ref is used in <NavbarMenu />
17
- forwardedRef
18
- ): ReactElement {
19
- if (newWindow) {
20
- return (
21
- <Link
22
- ref={forwardedRef}
23
- to={href}
24
- target="_blank"
25
- rel="noreferrer"
26
- className={$anchor.host}
27
- >
28
- {children}
29
- <span> (opens in a new tab)</span>
30
- </Link>
31
- )
32
- }
33
-
34
- if (!href) {
35
- return (
36
- <Link
37
- ref={forwardedRef}
38
- to={href}
39
- className={$anchor.host}
40
- >
41
- {children}
42
- </Link>
43
- )
44
- }
45
-
46
- return (
47
- <Link
48
- ref={forwardedRef}
49
- to={href}
50
- className={$anchor.host}
51
- >
52
- {children}
53
- </Link>
54
- )
55
- })
56
-
57
- UIAnchor.displayName = 'UIAnchor'
@@ -1,7 +0,0 @@
1
- export {
2
- UIAnchor
3
- } from "./Anchor"
4
-
5
- export type {
6
- UIAnchorProps,
7
- } from "./Anchor";
@@ -1,87 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const $nav = {
4
- host: css`
5
- position: sticky;
6
- top: 0;
7
- z-index: 20;
8
- width: 100%;
9
- background: transparent;
10
- display: flex;
11
- `,
12
- shadow: css`
13
- pointer-events: none;
14
- position: absolute;
15
- z-index: -1;
16
- height: 100%;
17
- width: 100%;
18
- background-color: white;
19
- `,
20
- nav: css`
21
- display: flex;
22
- width: 100%;
23
- height: var(--xyd-navbar-height);
24
- align-items: center;
25
- justify-content: flex-end;
26
- gap: 8px;
27
- padding-left: calc(max(env(safe-area-inset-left), 16px));
28
- padding-right: calc(max(env(safe-area-inset-right), 16px));
29
- `,
30
- nav$$middle: css`
31
- display: grid;
32
- grid-template-columns: 1fr 1fr 1fr;
33
- align-items: center;
34
- `
35
- };
36
-
37
- export const $list = {
38
- host: css`
39
- display: flex;
40
- align-items: center;
41
- justify-content: center;
42
- gap: 8px;
43
- `,
44
- }
45
-
46
- export const $item = {
47
- host: css`
48
- font-size: 14px; /* 0.875rem */
49
- position: relative;
50
- white-space: nowrap;
51
- color: #4b5563; /* Gray-600 */
52
- padding: 6px 16px;
53
- display: flex;
54
- align-items: center;
55
- justify-content: center;
56
-
57
- &:hover {
58
- color: #1f2937; /* Gray-800 */
59
- }
60
-
61
- &[data-state="active"] {
62
- font-weight: bold;
63
- background: #f9f9f9;
64
- border-radius: 8px;
65
- }
66
- `,
67
- title1: css`
68
- position: absolute;
69
- inset: 0;
70
- text-align: center;
71
- align-items: center;
72
- display: flex;
73
- justify-content: center;
74
- `,
75
- title2: css`
76
- visibility: hidden;
77
- font-weight: 500;
78
- `,
79
- };
80
-
81
- export const $logo = {
82
- host: css`
83
- display: flex;
84
- align-items: center;
85
- margin-right: auto;
86
- `
87
- }
@@ -1,56 +0,0 @@
1
- import React from "react";
2
- import * as RadixTabs from "@radix-ui/react-tabs";
3
-
4
- import {$nav, $list, $item, $logo} from "./Nav.styles";
5
-
6
- export interface NavProps {
7
- children: React.ReactNode
8
- value: string
9
- onChange: (value: string) => void
10
- logo?: React.ReactNode;
11
- kind?: "middle"
12
- }
13
-
14
- export function Nav({children, value, onChange, logo, kind}: NavProps) {
15
- return <RadixTabs.Root asChild value={value} onValueChange={onChange}>
16
- <div className={`${$nav.host}`}>
17
- <div className={$nav.shadow}/>
18
- <nav className={`
19
- ${$nav.nav}
20
- ${kind === "middle" && $nav.nav$$middle}
21
- `}>
22
- <div className={`
23
- ${$logo.host}
24
- xyd_ui-comp-nav-logo
25
- `}>
26
- {logo}
27
- </div>
28
- <RadixTabs.List asChild>
29
- <div className={$list.host}>
30
- {children}
31
- </div>
32
- </RadixTabs.List>
33
- {kind === "middle" && <div/>}
34
- </nav>
35
- </div>
36
- </RadixTabs.Root>
37
- }
38
-
39
- export interface NavItemProps {
40
- children: React.ReactNode;
41
- href: string;
42
- value: string;
43
- }
44
-
45
- Nav.Item = function NavItem({children, value, href}) {
46
- return <RadixTabs.Trigger asChild value={value}>
47
- <a
48
- href={href}
49
- className={`${$item.host}`}
50
- >
51
- <span className={$item.title1}>{children}</span>
52
- <span className={$item.title2}>{children}</span>
53
- </a>
54
- </RadixTabs.Trigger>
55
- };
56
-
@@ -1,8 +0,0 @@
1
- export {
2
- Nav
3
- } from "./Nav"
4
-
5
- export type {
6
- NavProps,
7
- NavItemProps
8
- } from "./Nav";
@@ -1,24 +0,0 @@
1
- import { css } from "@linaria/core";
2
-
3
- export const $collapse = {
4
- container: css`
5
- transform: translateZ(0);
6
- overflow: hidden;
7
- transition: all 300ms ease-in-out;
8
-
9
- //@media (prefers-reduced-motion: reduce) {
10
- // transition: none;
11
- //}
12
- `,
13
- base: css`
14
- opacity: 0;
15
- transition: opacity 500ms ease-in-out;
16
-
17
- //@media (prefers-reduced-motion: reduce) {
18
- // transition: none;
19
- //}
20
- `,
21
- open: css`
22
- opacity: 1;
23
- `,
24
- };
@@ -1,84 +0,0 @@
1
- import React, {useEffect, useRef} from "react";
2
- import type {ReactElement, ReactNode} from "react";
3
- import {$collapse} from "./Collapse.styles";
4
-
5
- export interface UICollapseProps {
6
- children: ReactNode;
7
- isOpen: boolean;
8
- horizontal?: boolean;
9
- }
10
-
11
- export function UICollapse({
12
- children,
13
- isOpen,
14
- horizontal = false,
15
- }: UICollapseProps): ReactElement {
16
- const containerRef = useRef<HTMLDivElement>(null);
17
- const innerRef = useRef<HTMLDivElement>(null);
18
- const animationRef = useRef<number | null>(null);
19
- const initialOpen = useRef(isOpen);
20
- const initialRender = useRef(true);
21
-
22
- useEffect(() => {
23
- const container = containerRef.current;
24
- const inner = innerRef.current;
25
-
26
- if (animationRef.current) {
27
- clearTimeout(animationRef.current);
28
- }
29
- if (initialRender.current || !container || !inner) return;
30
-
31
- if (isOpen) {
32
- // Opening animation
33
- if (horizontal) {
34
- inner.style.width = `${inner.scrollWidth}px`;
35
- container.style.width = `${inner.scrollWidth}px`;
36
- } else {
37
- inner.style.height = `${inner.scrollHeight}px`;
38
- container.style.height = `${inner.scrollHeight}px`;
39
- }
40
-
41
- animationRef.current = window.setTimeout(() => {
42
- container.style.removeProperty(horizontal ? "width" : "height");
43
- }, 300);
44
- } else {
45
- // Closing animation
46
- if (horizontal) {
47
- const width = container.scrollWidth; // Cache current width
48
- container.style.width = `${width}px`; // Set to fixed width first
49
-
50
- // Force reflow for Firefox
51
- container.offsetWidth;
52
-
53
- container.style.width = "0px";
54
- } else {
55
- const height = container.scrollHeight; // Cache current height
56
- container.style.height = `${height}px`; // Set to fixed height first
57
-
58
- // Force reflow for Firefox
59
- container.offsetHeight;
60
-
61
- container.style.height = "0px";
62
- }
63
- }
64
- }, [horizontal, isOpen]);
65
-
66
- useEffect(() => {
67
- initialRender.current = false;
68
- }, []);
69
-
70
- return (
71
- <div
72
- ref={containerRef}
73
- className={`${$collapse.container}`}
74
- style={initialOpen.current || horizontal ? undefined : {height: 0}}
75
- >
76
- <div
77
- ref={innerRef}
78
- className={`${$collapse.base} ${isOpen ? $collapse.open : ""}`}
79
- >
80
- {children}
81
- </div>
82
- </div>
83
- );
84
- }
@@ -1,117 +0,0 @@
1
- import {css} from "@linaria/core";
2
-
3
- export const $sidebar = {
4
- host: css`
5
- background: #f9f9f9;
6
- height: 100%;
7
- border-radius: 0.5rem;
8
- display: flex;
9
- flex-direction: column;
10
- `,
11
- ul: css`
12
- overflow-y: auto;
13
- overflow-x: hidden;
14
- height: 100%;
15
- padding: 1rem;
16
-
17
- // TODO: get height of top
18
- //height: calc(100vh - 54px);
19
- `
20
- }
21
-
22
- export const $footer = {
23
- host: css`
24
- padding: 1rem;
25
- //box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
26
- box-shadow: 0 -2px 10px rgba(237, 237, 237, .1);
27
- //border: 1px solid rgb(227, 227, 235);
28
- //border-top: 1px solid rgb(227, 227, 235);
29
- border-top: 1px solid #ededed;
30
- `,
31
- item$host: css`
32
- display: flex;
33
- width: 100%;
34
- padding: 2px;
35
- color: #6e6e80;
36
- `,
37
- item: css`
38
- display: flex;
39
- align-items: center;
40
- width: 100%;
41
- gap: 7px;
42
- font-size: 14px;
43
- padding: 4px 8px;
44
-
45
- &:hover {
46
- background: #ececf1;
47
- color: #111827;
48
- border-radius: 4px;
49
-
50
- svg {
51
- fill: #111827;
52
- }
53
- }
54
-
55
- svg {
56
- fill: #6e6e80;
57
- font-size: 18px;
58
- width: 18px;
59
- height: 18px;
60
- }
61
- `
62
- }
63
-
64
- export const $item = {
65
- host: css`
66
- color: #6e6e80;
67
- font-size: 14px;
68
- `,
69
- link: css`
70
- display: flex;
71
- width: 100%;
72
- padding: 2px;
73
- font-weight: 500;
74
- `,
75
- link$$active: css`
76
- background: #fff;
77
- color: #7051d4;
78
- border-radius: 4px;
79
- `,
80
- link$$activeSecondary: css`
81
- background: unset;
82
- color: #111827;
83
- font-weight: 500;
84
- `,
85
- link$item: css`
86
- display: flex;
87
- width: 100%;
88
- padding: 4px 8px;
89
-
90
- &:hover {
91
- background: #ececf1;
92
- color: #111827;
93
- border-radius: 4px;
94
- }
95
- `
96
- }
97
-
98
- export const $tree = {
99
- host: css`
100
- margin-left: 8px;
101
- `,
102
- }
103
-
104
- export const $itemHeader = {
105
- host: css`
106
- // TODO: calc based on items?
107
- padding-left: 10px;
108
- margin-bottom: 6px;
109
- margin-top: 16px;
110
- font-size: 12px;
111
- line-height: 16px;
112
- font-weight: 600;
113
- letter-spacing: 1px;
114
- color: #111827;
115
- `
116
- }
117
-
@@ -1,121 +0,0 @@
1
- import React from "react"
2
-
3
- import {$sidebar, $footer, $item, $tree, $itemHeader} from "./Sidebar.styles";
4
- import {UICollapse} from "./Collapse";
5
-
6
- export interface UISidebarProps {
7
- children: React.ReactNode;
8
- footerItems?: React.ReactNode;
9
- }
10
-
11
- export function UISidebar({children, footerItems}: UISidebarProps) {
12
- // TODO: in the future theming api?
13
- return <div className={`
14
- ${$sidebar.host}
15
- xyd_ui-comp-sidebar
16
- `}>
17
- <ul className={$sidebar.ul}>
18
- {children}
19
- </ul>
20
- {footerItems && <SidebarFooter>
21
- {footerItems}
22
- </SidebarFooter>}
23
- </div>
24
- }
25
-
26
- export interface UISidebarItemProps {
27
- children: React.ReactNode;
28
- button?: boolean;
29
- href?: string;
30
- active?: boolean;
31
- activeTheme?: "secondary";
32
- onClick?: (v: any) => void
33
- }
34
-
35
- // TODO: move to ui
36
- function Link({children, ...props}) {
37
- return <a {...props}>
38
- {children}
39
- </a>
40
- }
41
-
42
- UISidebar.Item = function SidebarItem({
43
- children,
44
- button,
45
- href,
46
- active,
47
- activeTheme,
48
- onClick
49
- }: UISidebarItemProps) {
50
- const [firstChild, ...restChilds] = React.Children.toArray(children)
51
-
52
- const ButtonOrAnchor = button ? 'button' : Link
53
-
54
- return <li
55
- className={$item.host}
56
- >
57
- <ButtonOrAnchor
58
- href={button ? undefined : href}
59
- onClick={button ? onClick : undefined}
60
- className={`
61
- ${$item.link}
62
- `}
63
- >
64
- <div className={`
65
- ${$item.link$item}
66
- ${active && $item.link$$active}
67
- ${active && activeTheme === "secondary" && $item.link$$activeSecondary}
68
- `}>
69
- {firstChild}
70
- </div>
71
- </ButtonOrAnchor>
72
- {restChilds}
73
- </li>
74
- }
75
-
76
- export interface UISidebarItemHeaderProps {
77
- children: React.ReactNode;
78
- }
79
-
80
- UISidebar.ItemHeader = function SidebarItemHeader({children}: UISidebarItemHeaderProps) {
81
- return <li className={$itemHeader.host}>
82
- {children}
83
- </li>
84
- }
85
-
86
- export interface UISidebarSubTreeProps {
87
- children: React.ReactNode;
88
- isOpen?: boolean;
89
- }
90
-
91
- UISidebar.SubTree = function SidebarSubItem({children, isOpen}: UISidebarSubTreeProps) {
92
- return <ul className={$tree.host}>
93
- <UICollapse isOpen={isOpen || false}>
94
- {children}
95
- </UICollapse>
96
- </ul>
97
- }
98
-
99
- function SidebarFooter({children}: { children: React.ReactNode }) {
100
- return <div className={$footer.host}>
101
- <ul>
102
- {children}
103
- </ul>
104
- </div>
105
- }
106
-
107
- export interface SidebarFooterItemProps {
108
- children: React.ReactNode;
109
- href?: string;
110
- icon?: React.ReactNode;
111
- }
112
-
113
- UISidebar.FooterItem = function SidebarFooter({children, href, icon}: SidebarFooterItemProps) {
114
- return <li className={$footer.item$host}>
115
- <a className={$footer.item} href={href}>
116
- {icon}
117
- {children}
118
- </a>
119
- </li>
120
- }
121
-
@@ -1,11 +0,0 @@
1
- export {
2
- UISidebar,
3
- } from "./Sidebar";
4
-
5
- export type {
6
- UISidebarProps,
7
- UISidebarItemProps,
8
- UISidebarItemHeaderProps,
9
-
10
- SidebarFooterItemProps
11
- } from "./Sidebar";