Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added KMenu component #440

Merged
merged 74 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
db4d588
wip: init KMenu component
baiwusanyu-c Apr 15, 2024
2e6cf3d
wip: KMEnu api design
baiwusanyu-c Apr 15, 2024
747e776
wip: temp commit
baiwusanyu-c Apr 15, 2024
c7b1f03
wip: temp commit
baiwusanyu-c Apr 15, 2024
8a4f7f9
wip: recursive slots and dynamic context
baiwusanyu-c Apr 16, 2024
8292b95
wip: initial drawing of menu component inline mode
baiwusanyu-c Apr 16, 2024
f1f00c5
wip: KMenu component completes submenu expansion animation
baiwusanyu-c Apr 16, 2024
2ba3233
wip: KMenu component completes submenu expansion animation
baiwusanyu-c Apr 16, 2024
ea22ff8
wip: fix expend animation
baiwusanyu-c Apr 17, 2024
f625554
wip: complete the selected style of the KMenu component submenu
baiwusanyu-c Apr 17, 2024
9f39ad6
wip: KMenu component completes incremental changes in submenu backgro…
baiwusanyu-c Apr 17, 2024
f05ed44
wip: KMenu component completes inline mode default submenu expansion
baiwusanyu-c Apr 17, 2024
a760a5a
wip: KMenu component completes inline mode default submenu select item
baiwusanyu-c Apr 17, 2024
0882d56
wip: KMenu component completes inline mode expendIcon and item icon s…
baiwusanyu-c Apr 17, 2024
beadd41
wip: temp commit
baiwusanyu-c Apr 17, 2024
7073947
wip: KMenu component completes inline mode click event
baiwusanyu-c Apr 17, 2024
1a65321
wip: KMenu component completes inline mode openChange event
baiwusanyu-c Apr 18, 2024
54d6397
wip: KMenu component completes inline mode select event
baiwusanyu-c Apr 18, 2024
cd4e682
wip: updated todo list
baiwusanyu-c Apr 18, 2024
fc0d119
wip: remove types
baiwusanyu-c Apr 18, 2024
9c53c1b
wip: KMenu component completes inline mode selectable props
baiwusanyu-c Apr 19, 2024
522036c
wip:temp commit
baiwusanyu-c Apr 21, 2024
4566872
wip: KMenu component completes vertical mode group item render
baiwusanyu-c Apr 21, 2024
7633e40
wip: optimize the grouping style of KMenu component in vertical mode
baiwusanyu-c Apr 21, 2024
06305bf
wip: temp commit
baiwusanyu-c Apr 21, 2024
b0b0c1b
wip: fix gorup item render error
baiwusanyu-c Apr 21, 2024
72ad9fb
wip: KMenu component completes vertical mode subMenuCloseDelay and su…
baiwusanyu-c Apr 22, 2024
81854d4
wip: KMenu component completes vertical and inline mode onDeSelect event
baiwusanyu-c Apr 22, 2024
c5f8bcc
wip: KMenu component vertical mode openUids props temp commit
baiwusanyu-c Apr 22, 2024
6fefbd7
wip: complete KMenu component vertical mode openUids props
baiwusanyu-c Apr 22, 2024
024a978
wip: complete the styling of the KMenu component in horizontal mode
baiwusanyu-c Apr 23, 2024
a1a40a4
wip: optimization the styling of the KMenu component in horizontal mode
baiwusanyu-c Apr 23, 2024
65dc2cb
wip: complete KMenu component temp commit
baiwusanyu-c Apr 23, 2024
3d16806
wip: temp commit
baiwusanyu-c Apr 24, 2024
af38ed4
wip: complete KMenu component temp commit
baiwusanyu-c Apr 24, 2024
275cd8d
wip: horizontal mode is turned on by default and is compatible with
baiwusanyu-c Apr 25, 2024
969fe23
wip: set horizontal width more correctly
baiwusanyu-c Apr 25, 2024
add53d0
wip: Preliminary drawing of omitted icons
baiwusanyu-c Apr 26, 2024
ddbb701
wip: complete KMenu component horizontal mode omit display
baiwusanyu-c Apr 28, 2024
718ec97
wip: complete KMenu component label slots
Oct 10, 2024
1bb7eb5
wip: complete KMenu component inlineCollapsed prop
Oct 10, 2024
6f61491
wip: complete KMenu component title & label props
Oct 23, 2024
c6e12b6
wip: KTooltip added width props
Oct 23, 2024
cfc67b0
wip: complete KMenu component danger and popupClassName props
Oct 23, 2024
4ff0111
wip: complete KMenu component disabled props
Dec 23, 2024
c51d0ff
wip: complete KMenu component titleClick event
Dec 23, 2024
f998151
test: added KMenu unit test
Dec 24, 2024
5d17ab5
test: added KMenu onSelect and onDeSelect unit test
Dec 25, 2024
db152a7
test: added KMenu onOpenChange unit test
Jan 8, 2025
3783c1c
test: added KMenu selectable props unit test
baiwusanyu-c Jan 8, 2025
472d911
test: added KMenu expandIcon props unit test
baiwusanyu-c Jan 8, 2025
21eda6b
test: added KMenu expandIcon slots unit test
baiwusanyu-c Jan 8, 2025
4e9cb2d
test: added KMenu icon slots unit test
baiwusanyu-c Jan 8, 2025
f35ec41
test: added KMenu label slots unit test
baiwusanyu-c Jan 8, 2025
e4eddea
test: added KMenu onTitleClick unit test
Jan 10, 2025
fb0e66a
test: added unit test about type attribute with KMenuItem item props
Jan 10, 2025
98e5e8a
test: added unit test about icon attribute with KMenuItem item props
Jan 10, 2025
a672d56
test: added unit test about label attribute with KMenuItem item props
Jan 10, 2025
46b8d06
test: added unit test about children attribute with KMenuItem item props
Jan 10, 2025
c98e434
ci: use pnpm
Jan 10, 2025
68e1fb4
test: update unit test snap
Jan 10, 2025
6550732
chore: updated tour component unit test snap
baiwusanyu-c Jan 10, 2025
d95584d
test: added unit test about KMenu multiple props
baiwusanyu-c Jan 10, 2025
0954297
test: added unit test about danger attribute with KMenu item props
baiwusanyu-c Jan 10, 2025
525a27b
test: added unit test about disabled attribute with KMenu item props
baiwusanyu-c Jan 10, 2025
917f369
ci: use npm registry
baiwusanyu-c Jan 10, 2025
9d0028d
ci: use npm registry
baiwusanyu-c Jan 10, 2025
e5460ce
chore: updated deps lock
baiwusanyu-c Jan 10, 2025
991893a
ci: updated node version
baiwusanyu-c Jan 10, 2025
c009490
ci: updated node version
baiwusanyu-c Jan 10, 2025
e0cbb99
test: updated unit test snap
baiwusanyu-c Jan 10, 2025
ad9436e
feat: KMenu component support dark theme
baiwusanyu-c Jan 10, 2025
026d08c
feat: KMenu component added theme prop
baiwusanyu-c Jan 10, 2025
52448ea
fix: Properly adjust the height of the KMenu component in horizontal …
baiwusanyu-c Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: pnpm

- name: Install
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 🌈 Unit Test
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 # Skip downloading during yarn install
PLAYWRIGHT_BROWSERS_PATH: 0 # Places binaries to node_modules/@playwright/test

NPM_CONFIG_REGISTRY: https://registry.npmjs.org/
on:
push:
branches:
Expand All @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node: [18.x]
node: [20.x]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false

Expand All @@ -34,17 +34,20 @@ jobs:
- name: Set node
uses: actions/setup-node@v3
with:
node-version: 18.x
node-version: 20.x
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni
run: npm i -g pnpm

- name: Reset pnpm registry
run: pnpm config set registry https://registry.npmjs.org/

- name: Setup dependencies
run: nci
run: pnpm install --no-frozen-lockfile --registry=https://registry.npmjs.org/

- name: Build
run: nr build
run: pnpm build

- name: Unit Test
run: nr test:unit
run: pnpm test:unit

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions components/Dropdown/__test__/__snapshots__/dropdown.spec.ts.snap

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions components/Ellipsis/__test__/__snapshots__/ellipsis.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Test: KEllipsis > props: cls 1`] = `"<div aria-hidden="true" class="flex" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base k-ellipsis--test" slot="triggerEl" aria-hidden="true" style="">...</div></div> "`;
exports[`Test: KEllipsis > props: cls 1`] = `"<div aria-hidden="true" class="flex svelte-13arsd0" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base k-ellipsis--test" slot="triggerEl" aria-hidden="true" style="">...</div></div> "`;

exports[`Test: KEllipsis > props: content 1`] = `"<div aria-hidden="true" class="flex" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="">我言秋日胜春朝</div></div> <div class="k-popover--base k-popover--base__top k-popover--base__top__dark k-popover--base__dark svelte-13arsd0" data-popper-placement="top" aria-hidden="true" style="position: fixed; left: 0px; top: 0px; margin: 0px; animation: __svelte_3896445108_0 200ms linear 0ms 1 both; bottom: 8px;" data-popper-reference-hidden="" data-popper-escaped=""><span slot="contentEl">自古逢秋悲寂寥</span> <div k-popover-arrow="true" class="svelte-13arsd0" data-popper-arrow-top=""></div></div>"`;
exports[`Test: KEllipsis > props: content 1`] = `"<div aria-hidden="true" class="flex svelte-13arsd0" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="">我言秋日胜春朝</div></div> <div class="k-popover--base k-popover--base__top k-popover--base__top__dark k-popover--base__dark svelte-13arsd0" data-popper-placement="top" aria-hidden="true" style="position: fixed; left: 0px; top: 0px; margin: 0px; animation: __svelte_3896445108_0 200ms linear 0ms 1 both; bottom: 8px;" data-popper-reference-hidden="" data-popper-escaped=""><span slot="contentEl">自古逢秋悲寂寥</span> <div k-popover-arrow="true" class="svelte-13arsd0" data-popper-arrow-top=""></div></div>"`;

exports[`Test: KEllipsis > props: expand 1`] = `"<div aria-hidden="true" class="flex" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="-webkit-line-clamp: 3; display: -webkit-inline-box; overflow: hidden;">我言秋日...</div></div> "`;
exports[`Test: KEllipsis > props: expand 1`] = `"<div aria-hidden="true" class="flex svelte-13arsd0" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="-webkit-line-clamp: 3; display: -webkit-inline-box; overflow: hidden;">我言秋日...</div></div> "`;

exports[`Test: KEllipsis > props: num 1`] = `"<div aria-hidden="true" class="flex" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="">我言秋日...</div></div> "`;
exports[`Test: KEllipsis > props: num 1`] = `"<div aria-hidden="true" class="flex svelte-13arsd0" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="">我言秋日...</div></div> "`;

exports[`Test: KEllipsis > props: text 1`] = `"<div aria-hidden="true" class="flex" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="">我言秋日胜春朝</div></div> "`;
exports[`Test: KEllipsis > props: text 1`] = `"<div aria-hidden="true" class="flex svelte-13arsd0" data-popover-trigger=""><div class="k-ellipsis k-ellipsis--base" slot="triggerEl" aria-hidden="true" style="">我言秋日胜春朝</div></div> "`;
2 changes: 1 addition & 1 deletion components/Form/__test__/__snapshots__/form.spec.ts.snap

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion components/Icon/src/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
export let color: KIconProps['color'] = '';
export let cls: KIconProps['cls'] = '';
export let attrs: KIconProps['attrs'] = {};
export let theme: KIconProps['theme'] = undefined;

$: tag = btn ? 'button' : '';

Expand All @@ -30,7 +31,7 @@
$: cnames = clsx(
`${prefixCls}--base`,
{
[`${prefixCls}--base__dark`]: !color,
[`${prefixCls}--base__dark`]: !color && ((theme && theme === 'dark') || theme === undefined),
[`${prefixCls}--role-button`]: !!btn
},
`${prefixCls}-transition`,
Expand Down
4 changes: 4 additions & 0 deletions components/Icon/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export type KIconProps = {
width: string;
height: string;
color: string;
/**
* @internal
*/
theme?: 'dark' | 'light';
cls: ClassValue;
attrs: Record<string, string>;
};
163 changes: 163 additions & 0 deletions components/Menu/__test__/__snapshots__/menu.spec.ts.snap

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions components/Menu/__test__/fixture/action.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<script lang="ts">
import { KMenu, KMenuItem } from '@ikun-ui/menu';
import type { SubMenuType } from '@ikun-ui/menu';
let items: SubMenuType[] = [
{
label: 'Navigation Three - Su',
title: 'Navigation Three - Su',
uid: 'SubMenu',
popupClassName: 'ikun-test',
icon: 'i-carbon-logo-vue',
children: [
{
type: 'group',
label: 'Item 1',
title: 'Item 1',
popupClassName: 'ikun-test',
uid: 'asda',
// icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 1',
title: 'Option 1',
uid: 'setting:1',
popupClassName: 'ikun-test',
disabled: false,
// icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 3333 Option 3333 Option 3333',
title: 'Option 3333',
icon: 'i-carbon-logo-vue',
popupClassName: 'ikun-test',
uid: 'setting:3333'
}
]
},
{
label: 'Navigation Four-dv',
// icon: 'i-carbon-logo-react',
type: 'divider',
popupClassName: 'ikun-test',
uid: 'alipay-dv'
},
{
label: 'Option 2',
popupClassName: 'ikun-test',
uid: 'setting:2'
}
]
},
{
label: 'Item 2',
uid: 'asdqqda',
disabled: true,
popupClassName: 'ikun-test',
// icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 3',
popupClassName: 'ikun-test',
uid: 'setting:3'
},
{
label: 'Option 4',
popupClassName: 'ikun-test',
uid: 'setting:4'
}
]
}
]
}
];
</script>

<div class="w-full fsc">
<KMenu mode="vertical" triggerSubMenuAction="hover" ctxKey="11">
<KMenuItem {items} ctxKey="11" />
</KMenu>
<KMenu mode="vertical" triggerSubMenuAction="click" ctxKey="22">
<KMenuItem {items} ctxKey="22" />
</KMenu>
</div>
85 changes: 85 additions & 0 deletions components/Menu/__test__/fixture/children.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<script lang="ts">
import { KMenu, KMenuItem } from '@ikun-ui/menu';
import type { SubMenuType } from '@ikun-ui/menu';
let items: SubMenuType[] = [
{
label: 'Navigation Three - Su',
title: 'Navigation Three - Su',
uid: 'SubMenu',
popupClassName: 'ikun-test',
icon: 'i-carbon-logo-vue',
children: [
{
type: 'group',
label: 'Item 1',
title: 'Item 1',
popupClassName: 'ikun-test',
uid: 'asda',
icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 1',
title: 'Option 1',
uid: 'setting:1',
popupClassName: 'ikun-test',
disabled: false,
icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 3333 Option 3333 Option 3333',
title: 'Option 3333',
icon: 'i-carbon-logo-vue',
popupClassName: 'ikun-test',
uid: 'setting:3333'
}
]
},
{
label: 'Navigation Four-dv',
icon: 'i-carbon-logo-react',
type: 'divider',
popupClassName: 'ikun-test',
uid: 'alipay-dv'
},
{
label: 'Option 2',
popupClassName: 'ikun-test',
uid: 'setting:2'
}
]
},
{
label: 'Item 2',
uid: 'asdqqda',
disabled: true,
popupClassName: 'ikun-test',
icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 3',
popupClassName: 'ikun-test',
uid: 'setting:3'
},
{
label: 'Option 4',
popupClassName: 'ikun-test',
uid: 'setting:4'
}
]
}
]
}
];
</script>

<div class="w-full fsc">
<KMenu mode="vertical" id="children_test_vertical" triggerSubMenuAction="click" ctxKey="11">
<KMenuItem {items} ctxKey="11" />
</KMenu>
<KMenu mode="inline" id="children_test_inline" triggerSubMenuAction="click" ctxKey="22">
<KMenuItem {items} ctxKey="22" />
</KMenu>
<KMenu mode="horizontal" id="children_test_horizontal" triggerSubMenuAction="click" ctxKey="22">
<KMenuItem {items} ctxKey="22" />
</KMenu>
</div>
112 changes: 112 additions & 0 deletions components/Menu/__test__/fixture/click.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<script lang="ts">
import { KMenu, KMenuItem } from '@ikun-ui/menu';
import type { SubMenuType } from '@ikun-ui/menu';
let items: SubMenuType[] = [
{
label: 'Navigation Three - Su',
title: 'Navigation Three - Su',
uid: 'SubMenu',
popupClassName: 'ikun-test',
icon: 'i-carbon-logo-vue',
children: [
{
type: 'group',
label: 'Item 1',
title: 'Item 1',
popupClassName: 'ikun-test',
uid: 'asda',
// icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 1',
title: 'Option 1',
uid: 'setting:1',
popupClassName: 'ikun-test',
disabled: false,
// icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 3333 Option 3333 Option 3333',
title: 'Option 3333',
icon: 'i-carbon-logo-vue',
popupClassName: 'ikun-test',
uid: 'setting:3333'
}
]
},
{
label: 'Navigation Four-dv',
// icon: 'i-carbon-logo-react',
type: 'divider',
popupClassName: 'ikun-test',
uid: 'alipay-dv'
},
{
label: 'Option 2',
popupClassName: 'ikun-test',
uid: 'setting:2'
}
]
},
{
label: 'Item 2',
uid: 'asdqqda',
disabled: true,
popupClassName: 'ikun-test',
// icon: 'i-carbon-logo-vue',
children: [
{
label: 'Option 3',
popupClassName: 'ikun-test',
uid: 'setting:3'
},
{
label: 'Option 4',
popupClassName: 'ikun-test',
uid: 'setting:4'
}
]
}
]
}
];

let triggerTime = 0;
let res = {};
const handleClick = (item: CustomEvent) => {
res = item.detail;
triggerTime = triggerTime + 1;
};
</script>

<div class="w-full fsc">
<KMenu
mode="vertical"
id="click_test_vertical"
on:click={handleClick}
triggerSubMenuAction="click"
ctxKey="11"
>
<KMenuItem {items} ctxKey="11" />
</KMenu>
<KMenu
mode="inline"
id="click_test_inline"
triggerSubMenuAction="click"
on:click={handleClick}
ctxKey="22"
>
<KMenuItem {items} ctxKey="22" />
</KMenu>
<KMenu
mode="horizontal"
id="click_test_horizontal"
triggerSubMenuAction="click"
on:click={handleClick}
ctxKey="22"
>
<KMenuItem {items} ctxKey="22" />
</KMenu>
<div id="trigger_time">{triggerTime}</div>
<div>{JSON.stringify(res)}</div>
</div>
Loading
Loading