@operato/context 2.0.0-alpha.5 → 2.0.0-alpha.52
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/CHANGELOG.md +252 -0
- package/dist/src/layouts/ox-context-page-toolbar.d.ts +8 -3
- package/dist/src/layouts/ox-context-page-toolbar.js +6 -3
- package/dist/src/layouts/ox-context-page-toolbar.js.map +1 -1
- package/dist/src/layouts/ox-context-toolbar.d.ts +1 -1
- package/dist/src/tools/ox-page-action-context-bar.d.ts +11 -3
- package/dist/src/tools/ox-page-action-context-bar.js +21 -18
- package/dist/src/tools/ox-page-action-context-bar.js.map +1 -1
- package/dist/src/tools/ox-page-action-overlay-template.d.ts +1 -1
- package/dist/src/tools/ox-page-title-bar.d.ts +1 -1
- package/dist/src/tools/ox-title-bar.d.ts +1 -1
- package/dist/stories/ox-context-page-toolbar-select.stories.d.ts +24 -0
- package/dist/stories/ox-context-page-toolbar-select.stories.js +82 -0
- package/dist/stories/ox-context-page-toolbar-select.stories.js.map +1 -0
- package/dist/stories/ox-context-page-toolbar.stories.d.ts +24 -0
- package/dist/stories/ox-context-page-toolbar.stories.js +87 -0
- package/dist/stories/ox-context-page-toolbar.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/layouts/ox-context-page-toolbar.ts +9 -3
- package/src/tools/ox-page-action-context-bar.ts +50 -38
- package/stories/ox-context-page-toolbar-select.stories.ts +96 -0
- package/stories/ox-context-page-toolbar.stories.ts +101 -0
- package/themes/app-theme.css +145 -0
|
@@ -82,7 +82,15 @@ export class PageActionContextBar extends connect(store)(LitElement) {
|
|
|
82
82
|
]
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
@
|
|
85
|
+
@property({ type: Array }) actions: {
|
|
86
|
+
title: string
|
|
87
|
+
action: () => void
|
|
88
|
+
icon: string
|
|
89
|
+
type: string
|
|
90
|
+
select: string[]
|
|
91
|
+
href?: string
|
|
92
|
+
emphasis?: boolean
|
|
93
|
+
}[] = []
|
|
86
94
|
@state() private overflown: boolean = false
|
|
87
95
|
|
|
88
96
|
private overflownUpdaterThrottle: any
|
|
@@ -128,42 +136,42 @@ export class PageActionContextBar extends connect(store)(LitElement) {
|
|
|
128
136
|
return type == 'text'
|
|
129
137
|
? html` <span @click=${action}>${title}</span> `
|
|
130
138
|
: type == 'select' || (select && select.length > 0)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
139
|
+
? html`
|
|
140
|
+
<select @change=${action}>
|
|
141
|
+
${select.map((option: any) => html` <option>${option}</option> `)}
|
|
142
|
+
</select>
|
|
143
|
+
`
|
|
144
|
+
: type == 'link'
|
|
145
|
+
? html` <a href=${href}>${title}</a> `
|
|
146
|
+
: type == 'icon'
|
|
147
|
+
? html`<mwc-icon @click=${action}>${icon}</mwc-icon>`
|
|
148
|
+
: html`
|
|
149
|
+
<mwc-button
|
|
150
|
+
label=${title}
|
|
151
|
+
icon=${icon || 'done_all'}
|
|
152
|
+
?dense=${dense}
|
|
153
|
+
?raised=${raised}
|
|
154
|
+
?outlined=${outlined}
|
|
155
|
+
?danger=${danger}
|
|
156
|
+
@click=${async (e: MouseEvent) => {
|
|
157
|
+
/* all actions should be bloked for a second */
|
|
158
|
+
const button = e.currentTarget as any
|
|
159
|
+
button.icon = 'rotate_right'
|
|
160
|
+
button.setAttribute('working', true)
|
|
161
|
+
button.disabled = true
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
await action()
|
|
165
|
+
} finally {
|
|
166
|
+
await sleep(1000)
|
|
167
|
+
button.disabled = false
|
|
168
|
+
/* because icon can be changed after sleep, don't use closure 'icon'. */
|
|
169
|
+
button.icon = this.actions[idx]?.icon || 'done_all'
|
|
170
|
+
button.removeAttribute('working')
|
|
171
|
+
}
|
|
172
|
+
}}
|
|
173
|
+
></mwc-button>
|
|
174
|
+
`
|
|
167
175
|
})}
|
|
168
176
|
`
|
|
169
177
|
}
|
|
@@ -175,7 +183,11 @@ export class PageActionContextBar extends connect(store)(LitElement) {
|
|
|
175
183
|
}
|
|
176
184
|
|
|
177
185
|
stateChanged(state: any) {
|
|
178
|
-
|
|
186
|
+
const { actions } = state.route?.context || {}
|
|
187
|
+
|
|
188
|
+
if (actions) {
|
|
189
|
+
this.actions = actions.filter((action: any) => !!action)
|
|
190
|
+
}
|
|
179
191
|
}
|
|
180
192
|
|
|
181
193
|
showMore() {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import '@material/mwc-icon'
|
|
2
|
+
import '../src/layouts/ox-context-page-toolbar.js'
|
|
3
|
+
import '../src/tools/ox-page-action-context-bar.js'
|
|
4
|
+
import { CommonHeaderStyles } from '@operato/styles'
|
|
5
|
+
import { TOOL_POSITION } from '@operato/layout'
|
|
6
|
+
|
|
7
|
+
import '@operato/styles'
|
|
8
|
+
|
|
9
|
+
import { css, html, render, TemplateResult } from 'lit'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'ox-context-page-toolbar-select',
|
|
13
|
+
component: 'ox-context-page-toolbar',
|
|
14
|
+
argTypes: {
|
|
15
|
+
label: { control: 'string' }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Story<T> {
|
|
20
|
+
(args: T): TemplateResult
|
|
21
|
+
args?: Partial<T>
|
|
22
|
+
argTypes?: Record<string, unknown>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ArgTypes {
|
|
26
|
+
label?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Template: Story<ArgTypes> = ({ label = '' }: ArgTypes) => html`
|
|
30
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
|
31
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
body {
|
|
35
|
+
background-color: white;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
${CommonHeaderStyles.cssText}
|
|
39
|
+
</style>
|
|
40
|
+
|
|
41
|
+
<div style="height:600px;">
|
|
42
|
+
<div class="header">
|
|
43
|
+
<div class="title">
|
|
44
|
+
<mwc-icon>summarize</mwc-icon>
|
|
45
|
+
${label}
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="filters">
|
|
49
|
+
<label>Filter</label><input type="text"></input>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<ox-context-page-toolbar class="actions"
|
|
53
|
+
.tools=${[
|
|
54
|
+
{
|
|
55
|
+
position: TOOL_POSITION.FRONT,
|
|
56
|
+
template: html` <mwc-icon>download</mwc-icon> `,
|
|
57
|
+
context: 'exportable'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
position: TOOL_POSITION.FRONT,
|
|
61
|
+
template: html` <mwc-icon>upload</mwc-icon> `,
|
|
62
|
+
context: 'importable'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
position: TOOL_POSITION.CENTER,
|
|
66
|
+
template: html`<ox-page-action-context-bar
|
|
67
|
+
.actions=${[
|
|
68
|
+
{
|
|
69
|
+
title: 'smile',
|
|
70
|
+
action: () => {},
|
|
71
|
+
select: ['', 'delete', 'hahaha', 'hohoho']
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: 'save',
|
|
75
|
+
action: () => {},
|
|
76
|
+
icon: 'save'
|
|
77
|
+
}
|
|
78
|
+
]}
|
|
79
|
+
></ox-page-action-context-bar>`
|
|
80
|
+
}
|
|
81
|
+
]}
|
|
82
|
+
.context=${{
|
|
83
|
+
exportable: true,
|
|
84
|
+
importable: true,
|
|
85
|
+
toolbar: false
|
|
86
|
+
}}
|
|
87
|
+
|
|
88
|
+
}> </ox-context-page-toolbar>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
`
|
|
92
|
+
|
|
93
|
+
export const Regular = Template.bind({})
|
|
94
|
+
Regular.args = {
|
|
95
|
+
label: 'common header styles'
|
|
96
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import '@material/mwc-icon'
|
|
2
|
+
import '../src/layouts/ox-context-page-toolbar.js'
|
|
3
|
+
import '../src/tools/ox-page-action-context-bar.js'
|
|
4
|
+
import { CommonHeaderStyles } from '@operato/styles'
|
|
5
|
+
import { TOOL_POSITION } from '@operato/layout'
|
|
6
|
+
|
|
7
|
+
import '@operato/styles'
|
|
8
|
+
|
|
9
|
+
import { css, html, render, TemplateResult } from 'lit'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'ox-context-page-toolbar',
|
|
13
|
+
component: 'ox-context-page-toolbar',
|
|
14
|
+
argTypes: {
|
|
15
|
+
label: { control: 'string' }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Story<T> {
|
|
20
|
+
(args: T): TemplateResult
|
|
21
|
+
args?: Partial<T>
|
|
22
|
+
argTypes?: Record<string, unknown>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ArgTypes {
|
|
26
|
+
label?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Template: Story<ArgTypes> = ({ label = '' }: ArgTypes) => html`
|
|
30
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
|
31
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
body {
|
|
35
|
+
background-color: white;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
${CommonHeaderStyles.cssText}
|
|
39
|
+
</style>
|
|
40
|
+
|
|
41
|
+
<div style="height:600px;">
|
|
42
|
+
<div class="header">
|
|
43
|
+
<div class="title">
|
|
44
|
+
<mwc-icon>summarize</mwc-icon>
|
|
45
|
+
${label}
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<div class="filters">
|
|
49
|
+
<label>Filter</label><input type="text"></input>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<ox-context-page-toolbar class="actions"
|
|
53
|
+
.tools=${[
|
|
54
|
+
{
|
|
55
|
+
position: TOOL_POSITION.FRONT,
|
|
56
|
+
template: html` <mwc-icon>download</mwc-icon> `,
|
|
57
|
+
context: 'exportable'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
position: TOOL_POSITION.FRONT,
|
|
61
|
+
template: html` <mwc-icon>upload</mwc-icon> `,
|
|
62
|
+
context: 'importable'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
position: TOOL_POSITION.CENTER,
|
|
66
|
+
template: html`<ox-page-action-context-bar
|
|
67
|
+
.actions=${[
|
|
68
|
+
{
|
|
69
|
+
title: 'save',
|
|
70
|
+
action: () => {},
|
|
71
|
+
icon: 'save'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: 'copy',
|
|
75
|
+
action: () => {},
|
|
76
|
+
icon: 'content_copy'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: 'delete',
|
|
80
|
+
action: () => {},
|
|
81
|
+
icon: 'delete'
|
|
82
|
+
}
|
|
83
|
+
]}
|
|
84
|
+
></ox-page-action-context-bar>`
|
|
85
|
+
}
|
|
86
|
+
]}
|
|
87
|
+
.context=${{
|
|
88
|
+
exportable: true,
|
|
89
|
+
importable: true,
|
|
90
|
+
toolbar: false
|
|
91
|
+
}}
|
|
92
|
+
|
|
93
|
+
}> </ox-context-page-toolbar>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
`
|
|
97
|
+
|
|
98
|
+
export const Regular = Template.bind({})
|
|
99
|
+
Regular.args = {
|
|
100
|
+
label: 'common header styles'
|
|
101
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
body {
|
|
2
|
+
/* theme color */
|
|
3
|
+
--primary-color-rgb: 130, 105, 96;
|
|
4
|
+
--primary-color: rgb(var(--primary-color-rgb));
|
|
5
|
+
--secondary-color-rgb: 78, 78, 90;
|
|
6
|
+
--secondary-color: rgb(var(--secondary-color-rgb));
|
|
7
|
+
--focus-color: var(--theme-white-color);
|
|
8
|
+
--primary-background-color: var(--secondary-color);
|
|
9
|
+
--secondary-background-color: #283644;
|
|
10
|
+
--main-section-background-color: #f5f2ee;
|
|
11
|
+
--theme-white-color: #fff;
|
|
12
|
+
--theme-black-color: rgba(0, 0, 0, 0.9);
|
|
13
|
+
|
|
14
|
+
--focus-background-color: var(--primary-color);
|
|
15
|
+
--primary-text-color: #3c3938;
|
|
16
|
+
--secondary-text-color: var(--primary-color);
|
|
17
|
+
|
|
18
|
+
--opacity-dark-color: rgba(0, 0, 0, 0.4);
|
|
19
|
+
--opacity-light-color: rgba(255, 255, 255, 0.8);
|
|
20
|
+
|
|
21
|
+
/* status color */
|
|
22
|
+
--status-success-color: #35a24a;
|
|
23
|
+
--status-warning-color: #ee8d03;
|
|
24
|
+
--status-danger-color: #d14946;
|
|
25
|
+
--status-info-color: #398ace;
|
|
26
|
+
|
|
27
|
+
/* common style */
|
|
28
|
+
--border-radius: 4px;
|
|
29
|
+
--border-dark-color: 1px solid rgba(0, 0, 0, 0.15);
|
|
30
|
+
--border-light-color: 1px solid rgba(255, 255, 255, 0.3);
|
|
31
|
+
|
|
32
|
+
--box-shadow: 2px 2px 3px 0px rgba(0, 0, 0, 0.1);
|
|
33
|
+
|
|
34
|
+
--theme-font: 'Noto', Helvetica;
|
|
35
|
+
|
|
36
|
+
--margin-default: 9px;
|
|
37
|
+
--margin-narrow: 4px;
|
|
38
|
+
--margin-wide: 15px;
|
|
39
|
+
--padding-default: var(--margin-default);
|
|
40
|
+
--padding-narrow: var(--margin-narrow);
|
|
41
|
+
--padding-wide: var(--margin-wide);
|
|
42
|
+
|
|
43
|
+
--scrollbar-thumb-color: rgba(57, 78, 100, 0.5);
|
|
44
|
+
--scrollbar-thumb-hover-color: var(--primary-color);
|
|
45
|
+
|
|
46
|
+
--fontsize-default: 14px;
|
|
47
|
+
--fontsize-small: 13px;
|
|
48
|
+
--fontsize-large: 16px;
|
|
49
|
+
|
|
50
|
+
/* app layout style */
|
|
51
|
+
--app-grid-template-area: 'header header header' 'nav main aside' 'nav footer aside';
|
|
52
|
+
|
|
53
|
+
/* title & description style */
|
|
54
|
+
--title-margin: var(--margin-narrow) 0;
|
|
55
|
+
--title-font: bold 24px var(--theme-font);
|
|
56
|
+
--title-text-color: var(--secondary-color);
|
|
57
|
+
--title-font-mobile: bold 20px var(--theme-font);
|
|
58
|
+
|
|
59
|
+
--page-description-margin: var(--margin-narrow) 0 var(--margin-wide) 0;
|
|
60
|
+
--page-description-font: normal var(--fontsize-default) / 1.2rem var(--theme-font);
|
|
61
|
+
--page-description-color: var(--secondary-text-color);
|
|
62
|
+
|
|
63
|
+
--subtitle-padding: 12px 5px 3px 5px;
|
|
64
|
+
--subtitle-font: bold 18px var(--theme-font);
|
|
65
|
+
--subtitle-text-color: var(--primary-color);
|
|
66
|
+
--subtitle-border-bottom: 1px solid var(--primary-color);
|
|
67
|
+
|
|
68
|
+
/* icon style */
|
|
69
|
+
--icon-tiny-size: 24px;
|
|
70
|
+
--icon-default-size: 36px;
|
|
71
|
+
--icon-big-size: 48px;
|
|
72
|
+
--icon-default-color: var(--theme-white-color);
|
|
73
|
+
|
|
74
|
+
/* material design component themes */
|
|
75
|
+
--mdc-theme-on-primary: var(--theme-white-color);
|
|
76
|
+
--mdc-theme-primary: var(--secondary-text-color);
|
|
77
|
+
--mdc-theme-on-secondary: var(--theme-white-color);
|
|
78
|
+
--mdc-theme-secondary: var(--primary-color);
|
|
79
|
+
--mdc-button-outline-color: var(--primary-color);
|
|
80
|
+
--mdc-danger-button-primary-color: var(--status-danger-color);
|
|
81
|
+
--mdc-danger-button-outline-color: var(--status-danger-color);
|
|
82
|
+
--mdc-button-outline-width: 1px;
|
|
83
|
+
--mdc-button-horizontal-padding: 16px;
|
|
84
|
+
|
|
85
|
+
/* button style */
|
|
86
|
+
--button-background-color: #fafbfc;
|
|
87
|
+
--button-background-focus-color: var(--primary-color);
|
|
88
|
+
--button-border: var(--border-dark-color);
|
|
89
|
+
--button-border-radius: var(--border-radius);
|
|
90
|
+
--button-margin: var(--margin-default) var(--margin-default) var(--margin-default) 0;
|
|
91
|
+
--button-padding: var(--padding-default);
|
|
92
|
+
--button-color: var(--secondary-color);
|
|
93
|
+
--button-font: normal 15px var(--theme-font);
|
|
94
|
+
--button-text-transform: capitalize;
|
|
95
|
+
--button-active-box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.2);
|
|
96
|
+
--button-activ-border: 1px solid var(--primary-color);
|
|
97
|
+
|
|
98
|
+
--button-primary-background-color: var(--primary-color);
|
|
99
|
+
--button-primary-active-background-color: var(--status-success-color);
|
|
100
|
+
--button-primary-padding: var(--margin-default) var(--margin-wide);
|
|
101
|
+
--button-primary-color: var(--theme-white-color);
|
|
102
|
+
--button-primary-font: bold 16px var(--theme-font);
|
|
103
|
+
|
|
104
|
+
/* table style */
|
|
105
|
+
--th-padding: var(--padding-default);
|
|
106
|
+
--th-border-top: 2px solid var(--secondary-color);
|
|
107
|
+
--th-text-transform: capitalize;
|
|
108
|
+
--th-font: bold var(--fontsize-small) var(--theme-font);
|
|
109
|
+
--th-color: rgba(var(--secondary-color-rgb), 0.8);
|
|
110
|
+
|
|
111
|
+
--tr-background-color: var(--theme-white-color);
|
|
112
|
+
--tr-background-odd-color: rgba(255, 255, 255, 0.4);
|
|
113
|
+
--tr-background-hover-color: #e1f5fe;
|
|
114
|
+
--td-border-line: 1px solid rgba(0, 0, 0, 0.05);
|
|
115
|
+
--td-border-bottom: 1px solid rgba(0, 0, 0, 0.09);
|
|
116
|
+
--td-padding: var(--padding-default);
|
|
117
|
+
--td-font: normal 13px var(--theme-font);
|
|
118
|
+
--td-color: var(--secondary-color);
|
|
119
|
+
|
|
120
|
+
--label-cell-background-color: #f6f6f6; /* th or td common background color */
|
|
121
|
+
|
|
122
|
+
/* form style */
|
|
123
|
+
--label-font: normal var(--fontsize-default) var(--theme-font);
|
|
124
|
+
--label-color: var(--secondary-color);
|
|
125
|
+
--label-text-transform: capitalize;
|
|
126
|
+
--input-margin: var(--margin-narrow) 0;
|
|
127
|
+
--input-padding: var(--padding-default);
|
|
128
|
+
--input-min-width: 200px;
|
|
129
|
+
--input-font: normal var(--fontsize-default) var(--theme-font);
|
|
130
|
+
--input-hint-font: normal var(--fontsize-small) var(--theme-font);
|
|
131
|
+
--input-hint-color: #666;
|
|
132
|
+
--input-container-max-width: 900px;
|
|
133
|
+
--fieldset-margin: var(--padding-wide) 0;
|
|
134
|
+
--fieldset-padding: 0 var(--padding-wide) var(--padding-wide) var(--padding-wide);
|
|
135
|
+
--legend-padding: var(--padding-default) 0;
|
|
136
|
+
--legend-color: var(--secondary-text-color);
|
|
137
|
+
--legend-font: bold 16px var(--theme-font);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@media only screen and (max-width: 460px) {
|
|
141
|
+
body {
|
|
142
|
+
/* subtitle style */
|
|
143
|
+
--subtitle-margin: 0;
|
|
144
|
+
}
|
|
145
|
+
}
|