Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 7c2f91d

Browse files
feat: more options to shape text
1 parent 1ac254a commit 7c2f91d

File tree

6 files changed

+29
-21
lines changed

6 files changed

+29
-21
lines changed

studio/src/app/components/editor/actions/element/app-actions-element/app-actions-element.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class AppActionsElement {
5555
private image: boolean = false;
5656

5757
@State()
58-
private shape: boolean = false;
58+
private shape: 'shape' | 'text' | undefined = undefined;
5959

6060
@Event() private blockSlide: EventEmitter<boolean>;
6161

@@ -249,8 +249,12 @@ export class AppActionsElement {
249249
return element && element.nodeName && element.nodeName.toLowerCase() === SlotType.MATH;
250250
}
251251

252-
private isElementShape(element: HTMLElement): boolean {
253-
return element && element.nodeName && element.nodeName.toLowerCase() === SlotType.DRAG_RESIZE_ROTATE;
252+
private isElementShape(element: HTMLElement): 'shape' | 'text' | undefined {
253+
if (!element || !element.nodeName || element.nodeName.toLowerCase() !== SlotType.DRAG_RESIZE_ROTATE) {
254+
return undefined;
255+
}
256+
257+
return element.hasAttribute('text') ? 'text' : 'shape';
254258
}
255259

256260
private isElementImage(element: HTMLElement): boolean {
@@ -393,7 +397,7 @@ export class AppActionsElement {
393397
}
394398

395399
private async clone() {
396-
if (this.shape) {
400+
if (this.shape !== undefined) {
397401
await this.cloneShape();
398402
} else {
399403
await this.cloneSlide();
@@ -407,7 +411,7 @@ export class AppActionsElement {
407411
return;
408412
}
409413

410-
if (store.state.deckBusy || !this.shape) {
414+
if (store.state.deckBusy || this.shape === undefined) {
411415
resolve();
412416
return;
413417
}
@@ -979,7 +983,7 @@ export class AppActionsElement {
979983
component: 'app-more-element-actions',
980984
componentProps: {
981985
notes: this.slide,
982-
copy: this.slide || this.shape,
986+
copy: this.slide || this.shape !== undefined,
983987
images: this.slideNodeName === 'deckgo-slide-aspect-ratio',
984988
},
985989
event: $event,
@@ -1053,7 +1057,7 @@ export class AppActionsElement {
10531057
}
10541058

10551059
private renderCopy() {
1056-
const classSlide: string | undefined = `wider-devices ${this.slide || this.shape ? '' : 'hidden'}`;
1060+
const classSlide: string | undefined = `wider-devices ${this.slide || this.shape !== undefined ? '' : 'hidden'}`;
10571061

10581062
return (
10591063
<ion-tab-button onClick={() => this.clone()} aria-label="Copy" color="primary" mode="md" disabled={store.state.deckBusy} class={classSlide}>
@@ -1099,7 +1103,7 @@ export class AppActionsElement {
10991103
}
11001104

11011105
private renderTransform() {
1102-
const classToggle: string | undefined = !this.slide && !this.shape ? undefined : 'hidden';
1106+
const classToggle: string | undefined = !this.slide && this.shape === undefined ? undefined : 'hidden';
11031107

11041108
return (
11051109
<ion-tab-button onClick={() => this.openTransform()} aria-label="Toggle element type" color="primary" mode="md" class={classToggle}>

studio/src/app/components/editor/app-select-target-element/app-select-target-element.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export class AppSelectTargetElement {
3838
@Prop()
3939
image: boolean = false;
4040

41+
@Prop()
42+
shape: boolean = false;
43+
4144
@Event()
4245
applyTo: EventEmitter<TargetElement>;
4346

@@ -142,7 +145,7 @@ export class AppSelectTargetElement {
142145
if (this.background) {
143146
return (
144147
<ion-segment-button value={TargetElement.BACKGROUND} mode="md">
145-
<ion-label>Background</ion-label>
148+
<ion-label>{this.shape ? 'Color' : 'Background'}</ion-label>
146149
</ion-segment-button>
147150
);
148151
} else {

studio/src/app/components/editor/styles/app-color-text-background/app-color-text-background.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ export class AppColorTextBackground {
2121
@Prop()
2222
deck: boolean = false;
2323

24-
@Prop()
25-
shape: boolean = false;
26-
2724
@Prop()
2825
colorType: 'text' | 'background' = 'text';
2926

studio/src/app/popovers/editor/style/app-element-style/app-element-style.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class AppElementStyle {
3535
math: boolean = false;
3636

3737
@Prop()
38-
shape: boolean = false;
38+
shape: 'shape' | 'text' | undefined = undefined;
3939

4040
@Prop()
4141
image: boolean = false;
@@ -164,8 +164,8 @@ export class AppElementStyle {
164164
}
165165

166166
private renderSelectTarget() {
167-
const elementTarget: boolean = !this.slide && !this.shape && !this.image;
168-
const transition: boolean = !this.slide && !this.code && !this.math && !this.shape && !this.demo;
167+
const elementTarget: boolean = !this.slide && this.shape !== 'shape' && !this.image;
168+
const transition: boolean = !this.slide && !this.code && !this.math && this.shape === undefined && !this.demo;
169169

170170
return (
171171
<app-select-target-element
@@ -177,6 +177,7 @@ export class AppElementStyle {
177177
code={this.code}
178178
image={this.image}
179179
sides={this.author || this.split}
180+
shape={this.shape === 'shape'}
180181
transition={transition}
181182
onApplyTo={($event: CustomEvent<TargetElement>) => this.selectApplyToTargetElement($event)}></app-select-target-element>
182183
);
@@ -231,7 +232,6 @@ export class AppElementStyle {
231232
selectedElement={this.selectedElement}
232233
moreColors={this.moreColors}
233234
slide={this.slide}
234-
shape={this.shape}
235235
onColorChange={() => this.emitStyleChange()}></app-color-text-background>,
236236
];
237237
}

studio/src/app/utils/editor/align.utils.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export enum TextAlign {
99

1010
export class AlignUtils {
1111
static async getAlignment(element: HTMLElement): Promise<TextAlign | undefined> {
12-
if (!element || !this.isElementText(element)) {
12+
if (!element || (!this.isElementText(element) && !this.isShapeText(element))) {
1313
return undefined;
1414
}
1515

@@ -30,6 +30,10 @@ export class AlignUtils {
3030
return isRTL() ? TextAlign.RIGHT : TextAlign.LEFT;
3131
}
3232

33+
private static isShapeText(element: HTMLElement): boolean {
34+
return element && element.nodeName && element.nodeName.toLowerCase() && SlotType.DRAG_RESIZE_ROTATE && element.hasAttribute('text');
35+
}
36+
3337
private static isElementText(element: HTMLElement): boolean {
3438
return (
3539
element &&

studio/src/components.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export namespace Components {
104104
"initCurrentColors": () => Promise<void>;
105105
"moreColors": boolean;
106106
"selectedElement": HTMLElement;
107-
"shape": boolean;
108107
"slide": boolean;
109108
}
110109
interface AppContact {
@@ -178,7 +177,7 @@ export namespace Components {
178177
"imgDidChange": EventEmitter<HTMLElement>;
179178
"math": boolean;
180179
"selectedElement": HTMLElement;
181-
"shape": boolean;
180+
"shape": 'shape' | 'text' | undefined;
182181
"slide": boolean;
183182
}
184183
interface AppEmbed {
@@ -340,6 +339,7 @@ export namespace Components {
340339
"headerFooter": boolean;
341340
"image": boolean;
342341
"qrCode": boolean;
342+
"shape": boolean;
343343
"sides": boolean;
344344
"slide": boolean;
345345
"textTarget": boolean;
@@ -1246,7 +1246,6 @@ declare namespace LocalJSX {
12461246
"moreColors"?: boolean;
12471247
"onColorChange"?: (event: CustomEvent<void>) => void;
12481248
"selectedElement"?: HTMLElement;
1249-
"shape"?: boolean;
12501249
"slide"?: boolean;
12511250
}
12521251
interface AppContact {
@@ -1330,7 +1329,7 @@ declare namespace LocalJSX {
13301329
"math"?: boolean;
13311330
"onStyleDidChange"?: (event: CustomEvent<void>) => void;
13321331
"selectedElement"?: HTMLElement;
1333-
"shape"?: boolean;
1332+
"shape"?: 'shape' | 'text' | undefined;
13341333
"slide"?: boolean;
13351334
}
13361335
interface AppEmbed {
@@ -1508,6 +1507,7 @@ declare namespace LocalJSX {
15081507
"image"?: boolean;
15091508
"onApplyTo"?: (event: CustomEvent<TargetElement>) => void;
15101509
"qrCode"?: boolean;
1510+
"shape"?: boolean;
15111511
"sides"?: boolean;
15121512
"slide"?: boolean;
15131513
"textTarget"?: boolean;

0 commit comments

Comments
 (0)