Skip to content

Commit a78e4bc

Browse files
committed
refactor(uip-editor): fework compact design and fix small inconsistency in editor section behaviour
1 parent f96e9f0 commit a78e4bc

File tree

3 files changed

+41
-22
lines changed

3 files changed

+41
-22
lines changed

Diff for: src/plugins/editor/editor.header.less

+22-18
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,24 @@ html {
2222
padding: 2px 10px;
2323
}
2424

25+
&-icon {
26+
display: inline-flex;
27+
width: 1.5rem;
28+
height: 1.25rem;
29+
margin-inline-end: 5px;
30+
31+
> svg {
32+
fill: currentColor;
33+
stroke: currentColor;
34+
}
35+
}
36+
2537
&-title {
2638
margin-inline-end: auto;
2739
}
2840

2941
&-title:not(:empty) {
42+
line-height: 1em;
3043
padding: 5px;
3144
}
3245

@@ -35,6 +48,7 @@ html {
3548
width: 25px;
3649
height: 25px;
3750
z-index: 2;
51+
justify-content: flex-end;
3852
}
3953

4054
&-trigger {
@@ -51,28 +65,18 @@ html {
5165
appearance: none;
5266
}
5367

54-
&.no-label {
68+
[compact] & {
69+
padding: 2px 4px;
5570
background: transparent;
71+
border-top: none;
5672
justify-content: center;
5773
}
58-
59-
&.no-label &-title {
60-
display: none;
74+
[compact] &-icon {
75+
margin: 0 auto;
6176
}
62-
63-
&.no-label &-trigger {
64-
left: 50%;
65-
width: 100px;
66-
transform: translateX(-50%);
67-
68-
background: var(--uip-editor-header-bg, transparent);
69-
border-radius: 50px 50px 0 0;
70-
opacity: 0.5;
71-
transition: opacity 0.3s ease-in-out;
72-
73-
&:hover {
74-
opacity: 1;
75-
}
77+
[compact] &-title,
78+
[compact] &::after {
79+
display: none;
7680
}
7781

7882
[collapsible] &::after {

Diff for: src/plugins/editor/editor.icon.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* eslint-disable-file max-len */
2+
import React from 'jsx-dom';
3+
4+
export const EditorIcon = (): SVGElement => (
5+
<svg xmlns="http://www.w3.org/2000/svg" fill="#1f1f1f" viewBox="0 0 34 20">
6+
<path stroke="none" d="m3.094 10.453 7.336 2.965v2.297L.844 11.273v-1.71l9.586-4.43V7.43l-7.336 3.023Zm11.191 9.012h-1.863L19.547.938h1.851l-7.113 18.527Zm17.133-9.082-7.746-3.035V5.12l10.008 4.43v1.71l-10.008 4.442v-2.25l7.746-3.07Z"/>
7+
</svg>
8+
) as SVGElement;

Diff for: src/plugins/editor/editor.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@ import {debounce} from '@exadel/esl/modules/esl-utils/async/debounce';
1111
import {bind, boolAttr, decorate, listen, memoize} from '@exadel/esl/modules/esl-utils/decorators';
1212

1313
import {UIPPlugin} from '../../core/base/plugin';
14-
import {UIPOptionIcons} from '../header/options/option-icons';
14+
import {CopyIcon} from '../copy/uip-copy.icon';
15+
16+
import {EditorIcon} from './editor.icon';
1517

1618
/**
1719
* Editor {@link UIPPlugin} custom element definition
1820
* Uses Codejar code editor to provide an ability to modify UIP state markup
1921
*/
2022
export class UIPEditor extends UIPPlugin {
2123
public static override is = 'uip-editor';
22-
public static override observedAttributes = ['collapsible', 'copy', 'label'];
24+
public static override observedAttributes = ['collapsible', 'compact', 'copy', 'label'];
2325

2426
/** Highlight method declaration */
2527
public static highlight = (editor: HTMLElement): void => Prism.highlightElement(editor, false);
2628

29+
/** Marker to make header compact */
30+
@boolAttr() public compact: boolean;
31+
2732
/** Marker to collapse editor area */
2833
@boolAttr() public collapsed: boolean;
2934

@@ -38,9 +43,10 @@ export class UIPEditor extends UIPPlugin {
3843
protected get $header(): HTMLElement {
3944
const type = this.constructor as typeof UIPEditor;
4045
return (
41-
<div class={type.is + '-header ' + (this.label ? '' : 'no-label')}>
46+
<div class={type.is + '-header '}>
47+
<span class={type.is + '-header-icon'} title={this.label}><EditorIcon/></span>
4248
<span class={type.is + '-header-title'}>{this.label}</span>
43-
{this.showCopy ? <uip-copy class={type.is + '-header-copy'}>{UIPOptionIcons.copySVG}</uip-copy> : ''}
49+
{this.showCopy ? <uip-copy class={type.is + '-header-copy'}><CopyIcon/></uip-copy> : ''}
4450
{this.collapsible ? <button class={type.is + '-header-trigger'} aria-label="Collapse/expand"/> : ''}
4551
</div>
4652
) as HTMLElement;
@@ -105,6 +111,7 @@ export class UIPEditor extends UIPPlugin {
105111

106112
protected override attributeChangedCallback(attrName: string, oldVal: string, newVal: string): void {
107113
super.attributeChangedCallback(attrName, oldVal, newVal);
114+
this.root?.classList.toggle(UIPEditor.is + '-compact', this.compact);
108115
this.$header.remove();
109116
memoize.clear(this, '$header');
110117
this.insertAdjacentElement('afterbegin', this.$header);

0 commit comments

Comments
 (0)