Skip to content

Commit 984432a

Browse files
committed
feat: inspector-sub-header for new global settings
1 parent 510b288 commit 984432a

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,4 @@ export { default as Popover } from './popover'
116116
export { default as HelpTooltip } from './help-tooltip'
117117
export { default as RichText } from './rich-text'
118118
export { default as SortablePicker } from './sortable-picker'
119+
export { default as InspectorSubHeader } from './inspector-sub-header'
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.stk-inspector-sub-header {
2+
display: flex;
3+
justify-content: space-between;
4+
align-items: center;
5+
gap: 8px;
6+
.components-base-control__label {
7+
flex: 1;
8+
margin: 0;
9+
}
10+
.stk-inspector-sub-header__trash {
11+
color: var(--stk-skin-error);
12+
}
13+
.stk-inspector-sub-header__reset {
14+
color: var(--stk-skin-error);
15+
.dashicon {
16+
font-size: 12px;
17+
}
18+
}
19+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { i18n } from 'stackable'
2+
import { Button } from '@wordpress/components'
3+
import { __ } from '@wordpress/i18n'
4+
5+
const NOOP = () => {}
6+
7+
const InspectorSubHeader = props => {
8+
const {
9+
onBack = NOOP,
10+
onTrash = NOOP,
11+
onReset = NOOP,
12+
title = '',
13+
showTrash = true,
14+
showReset = false,
15+
} = props
16+
return (
17+
<div className="stk-inspector-sub-header">
18+
<Button
19+
icon="arrow-left-alt2"
20+
alt={ __( 'Back', i18n ) }
21+
onClick={ onBack }
22+
/>
23+
<h2 className="components-base-control__label">{ title }</h2>
24+
{ showTrash && (
25+
<Button
26+
className="stk-inspector-sub-header__trash"
27+
size="small"
28+
icon="trash"
29+
alt={ __( 'Delete', i18n ) }
30+
onTrash={ onTrash }
31+
/>
32+
) }
33+
{ showReset && (
34+
<Button
35+
className="stk-inspector-sub-header__reset"
36+
size="small"
37+
icon="image-rotate"
38+
alt={ __( 'Reset', i18n ) }
39+
onReset={ onReset }
40+
/>
41+
) }
42+
</div>
43+
)
44+
}
45+
46+
export default InspectorSubHeader

0 commit comments

Comments
 (0)