Skip to content

Commit

Permalink
#25276 Adding initial code preview works
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelrojas committed Aug 3, 2023
1 parent 524e70e commit cf1f556
Show file tree
Hide file tree
Showing 15 changed files with 210 additions and 24 deletions.
Expand Up @@ -76,6 +76,10 @@ export class DotPageStateService {
}

this.requestPage(options).subscribe((pageState: DotPageRenderState) => {
if (!pageState.viewAs.device) {
pageState.viewAs.device = options.viewAs?.device;
}

this.setState(pageState);
});
}
Expand Down
Expand Up @@ -15,11 +15,11 @@ <h3 class="dot-device-selector__header-title">
<ul class="device-list">
<li class="device-list-item" *ngFor="let option of defaultOptions">
<button class="device-list__button" (click)="change(option)">
<i [class]="option.icon"></i>
<i class="device-list-item__icon" [class]="option.icon"></i>
<div class="device-list-item__content">
<span class="device-list-item__name">{{ option.name }}</span>
<span class="device-list-item__dimensions">
{{ option.cssHeight }} x {{ option.cssWidth }}
{{ option.cssHeight | number }} x {{ option.cssWidth | number }}
</span>
</div>
</button>
Expand All @@ -36,9 +36,10 @@ <h3 class="dot-device-selector__header-title">
(click)="change(option); op.toggle($event)"
>
<div class="device-list-item__content">
<span>{{ option.name }}</span>
<span class="device-list-item__name">{{ option.name }}</span>
<span class="device-list-item__dimensions"
>{{ option.cssHeight }} x {{ option.cssWidth }}</span
>{{ option.cssHeight | number }} x
{{ option.cssWidth | number }}</span
>
</div>
</button>
Expand All @@ -60,7 +61,7 @@ <h3 class="dot-device-selector__header-title">
class="device-list-item device-list-item-media"
*ngFor="let tile of socialMediaTiles"
>
<i [class]="tile.icon"></i>
<i class="device-list-item__icon" [class]="tile.icon"></i>
{{ tile.label }}
</li>
</ul>
Expand All @@ -76,7 +77,7 @@ <h3 class="dot-device-selector__header-title">
<div class="dot-device-selector__content">
<ul class="device-list">
<li class="device-list-item device-list-item-media">
<i class="pi pi-google"></i>
<i class="pi pi-google device-list-item__icon"></i>
Google
</li>
</ul>
Expand All @@ -88,9 +89,3 @@ <h3 class="dot-device-selector__header-title">
</div>
</div>
</p-overlayPanel>
<p-button
(click)="op.toggle($event)"
icon="pi pi-angle-down"
styleClass=" p-button-text"
data-testId="device-selector-button"
></p-button>
Expand Up @@ -18,10 +18,10 @@
}

.dot-device-selector__header-title {
font-size: $font-size-lg;
font-size: 1.25rem;
font-style: normal;
font-weight: 500;
line-height: 140%;
color: $black;
}

.dot-device-selector__column {
Expand Down Expand Up @@ -68,10 +68,12 @@

.device-list-item__dimensions {
color: $color-palette-gray-600;
font-size: 0.875rem;
font-weight: 400;
}

.device-list-item__name {
line-height: 1;
margin-bottom: 6px;
}

.device-list-item.device-list-item-media {
Expand All @@ -90,6 +92,10 @@
}
}

.device-list-item__icon {
color: $color-palette-gray-600;
}

::ng-deep {
.p-overlaypanel.dot-device-selector__overlayPanel {
.p-overlaypanel-content {
Expand Down
Expand Up @@ -7,14 +7,15 @@ import {
EventEmitter,
Input,
OnInit,
Output
Output,
ViewChild
} from '@angular/core';
import { FormsModule } from '@angular/forms';

import { ButtonModule } from 'primeng/button';
import { DividerModule } from 'primeng/divider';
import { DropdownModule } from 'primeng/dropdown';
import { OverlayPanelModule } from 'primeng/overlaypanel';
import { OverlayPanel, OverlayPanelModule } from 'primeng/overlaypanel';
import { PanelModule } from 'primeng/panel';

import { filter, mergeMap, take, toArray } from 'rxjs/operators';
Expand Down Expand Up @@ -46,6 +47,7 @@ import { DotPipesModule } from '@pipes/dot-pipes.module';
export class DotDeviceSelectorSeoComponent implements OnInit {
@Input() value: DotDevice;
@Output() selected = new EventEmitter<DotDevice>();
@ViewChild('op') overlayPanel: OverlayPanel;

options$: Observable<DotDevice[]>;
socialMediaTiles = [
Expand Down Expand Up @@ -121,6 +123,10 @@ export class DotDeviceSelectorSeoComponent implements OnInit {
this.selected.emit(device);
}

public openMenu(event: Event) {
this.overlayPanel.toggle(event);
}

/**
* Load the options for the select
*
Expand Down
@@ -1,18 +1,25 @@
<p-selectButton
<!-- <p-selectButton
class="p-button-tabbed"
[(ngModel)]="mode"
[options]="options"
(onChange)="stateSelectorHandler($event.value)"
data-testId="selectButton"
></p-selectButton>
></p-selectButton> -->

<dot-device-selector-seo
#op
[pTooltip]="pageState.viewAs.device?.name || ('editpage.viewas.default.device' | dm)"
(selected)="changeDeviceHandler($event)"
appendTo="body"
tooltipPosition="bottom"
tooltipStyleClass="dot-device-selector__dialog"
></dot-device-selector-seo>

<dot-tab-buttons
[mode]="mode"
(eventOpen)="op.openMenu($event)"
(changeState)="stateSelectorHandler($event.target.value)"
></dot-tab-buttons>
<ng-container *ngIf="!variant">
<p-inputSwitch
#locker
Expand Down
Expand Up @@ -33,7 +33,7 @@ import {
DotPageRenderState,
DotVariantData
} from '@dotcms/dotcms-models';
import { DotMessagePipe } from '@dotcms/ui';
import { DotTabButtonsComponent, DotMessagePipe } from '@dotcms/ui';
import { DotPipesModule } from '@pipes/dot-pipes.module';
import { DotPageStateService } from '@portlets/dot-edit-page/content/services/dot-page-state/dot-page-state.service';

Expand Down Expand Up @@ -61,7 +61,8 @@ enum DotConfirmationType {
TooltipModule,
ButtonModule,
DotDeviceSelectorSeoComponent,
DotEditPageLockInfoSeoComponent
DotEditPageLockInfoSeoComponent,
DotTabButtonsComponent
]
})
export class DotEditPageStateControllerSeoComponent implements OnChanges {
Expand Down
Expand Up @@ -36,16 +36,17 @@ <h2>{{ variant.experimentName }}</h2>
></dot-edit-page-state-controller-seo>
</div>

<div class="lower-toolbar-right w-6">
<div class="lower-toolbar-right w-6" style="justify-content: flex-end">
<p-checkbox
class="flex w-7 dot-edit__what-changed-button"
class="flex dot-edit__what-changed-button"
*ngIf="showWhatsChanged && isEnterpriseLicense$ | async"
[binary]="true"
[label]="'dot.common.whats.changed' | dm"
(onChange)="whatschange.emit($event.checked)"
style="margin-right: 1rem"
></p-checkbox>
<dot-edit-page-view-as-controller-seo
class="flex w-5 gap-2"
class="flex gap-2"
[pageState]="pageState"
[variant]="variant"
>
Expand Down
Expand Up @@ -16,6 +16,14 @@
(delete)="deletePersonalization($event)"
(selected)="changePersonaHandler($event)"
></dot-persona-selector>

<p-checkbox
class="flex w-7 dot-edit__what-changed-button"
*ngIf="showWhatsChanged && isEnterpriseLicense$ | async"
[binary]="true"
[label]="'dot.common.whats.changed' | dm"
(onChange)="whatschange.emit($event.checked)"
></p-checkbox>
</ng-container>

<ng-template #language>
Expand Down
Expand Up @@ -7,6 +7,7 @@
.page-tools-list {
list-style: none;
padding: 0;
margin-top: 0;
}

.page-tools-list__item {
Expand Down Expand Up @@ -75,6 +76,10 @@
opacity: 0;
}
}

.p-dialog-content {
padding: 0 1rem;
}
}

&.p-dialog-mask.p-component-overlay {
Expand Down
Expand Up @@ -19,6 +19,8 @@
flex-wrap: wrap;
background-color: $white;
border-bottom: solid 1px $color-palette-gray-300;
height: 60px;
align-items: center;
}

::ng-deep {
Expand Down
1 change: 1 addition & 0 deletions core-web/libs/ui/src/index.ts
Expand Up @@ -8,3 +8,4 @@ export * from './lib/dot-field-required/dot-field-required.directive';
export * from './lib/dot-message/dot-message.pipe';
export * from './lib/dot-site-selector/dot-site-selector.directive';
export * from './lib/components/dot-empty-container/dot-empty-container.component';
export * from './lib/dot-tab-buttons/dot-tab-buttons.component';
@@ -0,0 +1,30 @@
<div class="dot-tab-buttons">
<div style="position: relative">
<button
class="dot-tab-button"
[ngClass]="{ 'dot-tab-button-hover': mode === pageMode.EDIT }"
[value]="pageMode.EDIT"
(click)="onChangeState($event)"
>
Edit
</button>
<div class="dot-tab-buttons-select" *ngIf="mode === pageMode.EDIT"></div>
</div>

<div style="position: relative">
<div
class="dot-button-dropdown"
[ngClass]="{ 'dot-tab-button-hover': mode === pageMode.PREVIEW }"
(click)="onChangeState($event)"
>
<button class="dot-tab-button__right" [value]="pageMode.PREVIEW">Preview</button>
<button
class="dot-tab-dropdown"
[ngClass]="{ 'dot-tab-button-hover-dropdown': mode === pageMode.PREVIEW }"
>
<i [class]="icon"></i>
</button>
</div>
<div class="dot-tab-buttons-select" *ngIf="mode === pageMode.PREVIEW"></div>
</div>
</div>
@@ -0,0 +1,62 @@
@use "variables" as *;

.dot-tab-buttons {
display: flex;
flex-direction: row;
gap: 0.25rem;
margin-right: 2rem;
}

.dot-tab-button {
border: 1.5px solid $color-palette-gray-200;
color: $color-palette-primary-500;
background-color: transparent;
padding: 0.5rem $spacing-3;
border-radius: 0.375rem;
height: 2.5rem;
}

.dot-tab-button__right {
border: 1.5px solid $color-palette-gray-200;
color: $color-palette-primary-500;
background-color: transparent;
padding: 0 0.5rem 0 1rem;
height: 2.5rem;
border-right: 0;
border-top-left-radius: 0.375rem;
border-bottom-left-radius: 0.375rem;
}

.dot-tab-dropdown {
background-color: transparent;
border: 1.5px solid $color-palette-gray-200;
height: 2.5rem;
border-top-right-radius: 0.375rem;
border-bottom-right-radius: 0.375rem;
border-left: 0;
padding: 0.5rem;
color: $color-palette-primary-500;
}

.dot-button-dropdown {
display: flex;
}

.dot-tab-buttons-select {
height: 0.25rem;
border-radius: 6.25rem;
width: auto;
background-color: $color-palette-primary-500;
left: 0;
right: 0;
bottom: -0.6rem;
position: absolute;
}

.dot-tab-button-hover {
background: $color-palette-primary-100;
}

.dot-tab-button-hover-dropdown {
background: $color-palette-primary-200;
}
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { DotTabButtonsComponent } from './dot-tab-buttons.component';

describe('DotTabButtonsComponent', () => {
let component: DotTabButtonsComponent;
let fixture: ComponentFixture<DotTabButtonsComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DotTabButtonsComponent]
}).compileComponents();

fixture = TestBed.createComponent(DotTabButtonsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

0 comments on commit cf1f556

Please sign in to comment.