Skip to content

Commit

Permalink
[duoyun-ui] Add <dy-pat-footer> <dy-pat-nav>
Browse files Browse the repository at this point in the history
  • Loading branch information
mantou132 committed Jan 21, 2024
1 parent 046bad3 commit 28c46c0
Show file tree
Hide file tree
Showing 11 changed files with 790 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/duoyun-ui/docs/zh/01-guide/55-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ render(
html`
<dy-pat-console
name="DuoyunUI"
logo="https://duoyun-ui.gemjs.org/logo.png"
.logo=${'https://duoyun-ui.gemjs.org/logo.png'}
.routes=${routes}
.navItems=${navItems}
.contextMenus=${contextMenus}
Expand Down
2 changes: 1 addition & 1 deletion packages/duoyun-ui/docs/zh/30-blog/200-crud.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ render(
html`
<dy-pat-console
name="DuoyunUI"
logo="https://duoyun-ui.gemjs.org/logo.png"
.logo=${'https://duoyun-ui.gemjs.org/logo.png'}
.routes=${routes}
.navItems=${navItems}
.contextMenus=${contextMenus}
Expand Down
6 changes: 6 additions & 0 deletions packages/duoyun-ui/src/lib/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const defaultIcons = {
search: genIcon(
`M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z`,
),
outward: genIcon(
'',
raw`
<polygon points="6,6 6,8 14.59,8 5,17.59 6.41,19 16,9.41 16,18 18,18 18,6" />
`,
),
menu: genIcon(`M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z`),
filter: genIcon(`M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z`),
more: genIcon(
Expand Down
8 changes: 4 additions & 4 deletions packages/duoyun-ui/src/lib/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { theme } from '../lib/theme';
// global style: `::selection`, `::target-text`, `::highlight`
// https://bugzilla.mozilla.org/show_bug.cgi?id=1868009
export const focusStyle = createCSSSheet(css`
:host(:focus),
:focus {
:host(:where(:focus)),
:where(:focus) {
outline: none;
}
:host(:focus-visible),
:focus-visible {
:host(:where(:focus-visible)),
:where(:focus-visible) {
outline: 2px solid ${theme.focusColor};
outline-offset: -2px;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/duoyun-ui/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,8 @@ export function createCacheStore<T extends Record<string, any>>(
const [store, , save] = useCacheStore(storageKey, initStore, options);
return [store, save] as const;
}

// 是链接需要使用 img 渲染
export function isRemoteIcon(icon: string | Element | DocumentFragment): icon is string {
return typeof icon === 'string' && !!icon.trim().match(/^(http|[./])/);
}
19 changes: 9 additions & 10 deletions packages/duoyun-ui/src/patterns/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { NavItems } from '../elements/side-navigation';
import type { DuoyunUseElement } from '../elements/use';
import { DuoyunRouteElement, RouteItem, RoutesObject } from '../elements/route';
import { ContextMenu, ContextMenuItem } from '../elements/contextmenu';
import { isRemoteIcon } from '../lib/utils';

import '../elements/title';
import '../elements/use';
Expand Down Expand Up @@ -142,7 +143,8 @@ const style = createCSSSheet(
: rules,
);

const globalStyle = createCSSSheet(css`
// 禁止向皮条
const consoleStyle = createCSSSheet(css`
::selection,
::target-text {
color: white;
Expand All @@ -152,22 +154,19 @@ const globalStyle = createCSSSheet(css`
color: white;
background: ${theme.informativeColor};
}
:root {
:where(:root) {
font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans',
'PingFang SC', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
html {
height: 100%;
overflow: hidden;
}
body {
:where(body) {
height: 100%;
overflow: auto;
scrollbar-width: thin;
overscroll-behavior: none;
margin: 0;
padding: 0;
}
`);

Expand All @@ -176,14 +175,14 @@ const globalStyle = createCSSSheet(css`
*/
@customElement('dy-pat-console')
@adoptedStyle(style)
@adoptedStyle(globalStyle)
@adoptedStyle(consoleStyle)
export class DyPatConsoleElement extends GemElement {
@boolattribute keyboardAccess: boolean;
@boolattribute screencastMode: boolean;
@boolattribute responsive: boolean;
@attribute logo: string;
@attribute name: string;

@property logo: string | Element | DocumentFragment;
@property routes?: Routes;
@property navItems?: NavItems;
@property contextMenus?: ContextMenus;
Expand Down Expand Up @@ -224,7 +223,7 @@ export class DyPatConsoleElement extends GemElement {
return html`
<dy-title hidden .suffix=${mediaQuery.isPWA ? '' : this.name && ` - ${this.name}`}></dy-title>
<div class="sidebar">
${this.logo.trim().match(/^(http|[./])/)
${isRemoteIcon(this.logo)
? html`<img class="logo" alt="Logo" src=${this.logo}></img>`
: html`<dy-use class="logo" .element=${this.logo}></dy-use>`}
<dy-side-navigation class="navigation" .items=${this.navItems}></dy-side-navigation>
Expand Down
Loading

0 comments on commit 28c46c0

Please sign in to comment.