Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(styles): isolating global styles #683

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions blocks/CameraSource/CameraSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class CameraSource extends UploaderBlock {
* @param {'granted' | 'denied' | 'prompt'} state
*/
_setPermissionsState = debounce((state) => {
this.classList.toggle('initialized', state === 'granted');
this.classList.toggle('uc-initialized', state === 'granted');

if (state === 'granted') {
this.set$({
Expand Down Expand Up @@ -215,38 +215,38 @@ export class CameraSource extends UploaderBlock {

CameraSource.template = /* HTML */ `
<lr-activity-header>
<button type="button" class="mini-btn" set="onclick: *historyBack">
<button type="button" class="uc-mini-btn" set="onclick: *historyBack">
<lr-icon name="back"></lr-icon>
</button>
<div set="@hidden: !cameraSelectHidden">
<lr-icon name="camera"></lr-icon>
<span l10n="caption-camera"></span>
</div>
<lr-select
class="camera-select"
class="uc-camera-select"
set="$.options: cameraSelectOptions; @hidden: cameraSelectHidden; onchange: onCameraSelectChange"
>
</lr-select>
<button type="button" class="mini-btn close-btn" set="onclick: *closeModal">
<button type="button" class="uc-mini-btn uc-close-btn" set="onclick: *closeModal">
<lr-icon name="close"></lr-icon>
</button>
</lr-activity-header>
<div class="content">
<div class="uc-content">
<video
autoplay
playsinline
set="srcObject: video; style.transform: videoTransformCss; @hidden: videoHidden"
ref="video"
></video>
<div class="message-box" set="@hidden: messageHidden">
<div class="uc-message-box" set="@hidden: messageHidden">
<span l10n="l10nMessage"></span>
<button
type="button"
set="onclick: onRequestPermissions; @hidden: requestBtnHidden"
l10n="camera-permissions-request"
></button>
</div>
<button type="button" class="shot-btn" set="onclick: onShot; @disabled: shotBtnDisabled">
<button type="button" class="uc-shot-btn" set="onclick: onShot; @disabled: shotBtnDisabled">
<lr-icon name="camera"></lr-icon>
</button>
</div>
Expand Down
20 changes: 10 additions & 10 deletions blocks/CameraSource/camera-source.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lr-camera-source {
max-height: var(--modal-max-content-height);
}

lr-camera-source.initialized {
lr-camera-source.uc-initialized {
height: max-content;
}

Expand All @@ -37,7 +37,7 @@ lr-camera-source video {
border-radius: var(--uc-radius);
}

lr-camera-source .toolbar {
lr-camera-source .uc-toolbar {
position: absolute;
bottom: 0;
display: flex;
Expand All @@ -47,7 +47,7 @@ lr-camera-source .toolbar {
background-color: var(--uc-background);
}

lr-camera-source .content {
lr-camera-source .uc-content {
display: flex;
flex: 1;
justify-content: center;
Expand All @@ -57,7 +57,7 @@ lr-camera-source .content {
overflow: hidden;
}

lr-camera-source .message-box {
lr-camera-source .uc-message-box {
display: flex;
flex-direction: column;
grid-gap: 40px;
Expand All @@ -67,12 +67,12 @@ lr-camera-source .message-box {
color: var(--uc-foreground);
}

lr-camera-source .message-box button {
lr-camera-source .uc-message-box button {
color: var(--uc-primary-foreground);
background-color: var(--uc-primary);
}

lr-camera-source .shot-btn {
lr-camera-source .uc-shot-btn {
position: absolute;
bottom: 20px;
width: 58px;
Expand All @@ -87,21 +87,21 @@ lr-camera-source .shot-btn {
transform var(--uc-transition);
}

lr-camera-source .shot-btn:hover {
lr-camera-source .uc-shot-btn:hover {
transform: scale(1.05);
opacity: 1;
}

lr-camera-source .shot-btn:active {
lr-camera-source .uc-shot-btn:active {
transform: scale(1);
opacity: 1;
}

lr-camera-source .shot-btn[disabled] {
lr-camera-source .uc-shot-btn[disabled] {
bottom: -80px;
}

lr-camera-source .shot-btn lr-icon svg {
lr-camera-source .uc-shot-btn lr-icon svg {
width: 20px;
height: 20px;
}
8 changes: 4 additions & 4 deletions blocks/CloudImageEditor/src/CloudImageEditorBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ export class CloudImageEditorBlock extends Block {
);

this.sub('*tabId', (tabId) => {
this.ref['img-el'].className = classNames('image', {
image_hidden_to_cropper: tabId === TabId.CROP,
image_hidden_effects: tabId !== TabId.CROP,
this.ref['img-el'].className = classNames('uc-image', {
'uc-image_hidden_to_cropper': tabId === TabId.CROP,
'uc-image_hidden_effects': tabId !== TabId.CROP,
});
});

this.classList.add('editor_ON');
this.classList.add('uc-editor_ON');

this.sub('*networkProblems', (networkProblems) => {
this.$['presence.networkProblems'] = networkProblems;
Expand Down
24 changes: 12 additions & 12 deletions blocks/CloudImageEditor/src/CropFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ export class CropFrame extends Block {
let disableThumb = this._shouldThumbBeDisabled(direction);
groupNode.setAttribute(
'class',
classNames('thumb', {
'thumb--hidden': disableThumb,
'thumb--visible': !disableThumb,
classNames('uc-thumb', {
'uc-thumb--hidden': disableThumb,
'uc-thumb--visible': !disableThumb,
}),
);
}
Expand Down Expand Up @@ -220,7 +220,7 @@ export class CropFrame extends Block {
for (let j = 0; j < 3; j++) {
let direction = /** @type {import('./types.js').Direction} */ (`${['n', '', 's'][i]}${['w', '', 'e'][j]}`);
let groupNode = createSvgNode('g');
groupNode.classList.add('thumb');
groupNode.classList.add('uc-thumb');
groupNode.setAttribute('with-effects', '');
let interactionNode = createSvgNode('rect', {
fill: 'transparent',
Expand Down Expand Up @@ -288,7 +288,7 @@ export class CropFrame extends Block {
svg.appendChild(line);
}

svg.classList.add('guides', 'guides--semi-hidden');
svg.classList.add('uc-guides', 'uc-guides--semi-hidden');

return svg;
}
Expand Down Expand Up @@ -452,9 +452,9 @@ export class CropFrame extends Block {
.forEach((groupNode) => {
groupNode.setAttribute(
'class',
classNames('thumb', {
'thumb--hidden': !visible,
'thumb--visible': visible,
classNames('uc-thumb', {
'uc-thumb--hidden': !visible,
'uc-thumb--visible': visible,
}),
);
});
Expand Down Expand Up @@ -488,9 +488,9 @@ export class CropFrame extends Block {
this._frameGuides.setAttribute(
'class',
classNames({
'guides--hidden': this._guidesHidden,
'guides--visible': !this._guidesHidden && dragging,
'guides--semi-hidden': !this._guidesHidden && !dragging,
'uc-guides--hidden': this._guidesHidden,
'uc-guides--visible': !this._guidesHidden && dragging,
'uc-guides--semi-hidden': !this._guidesHidden && !dragging,
}),
);
});
Expand All @@ -508,4 +508,4 @@ export class CropFrame extends Block {
}
}

CropFrame.template = /* HTML */ ` <svg class="svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg> `;
CropFrame.template = /* HTML */ ` <svg class="uc-svg" ref="svg-el" xmlns="http://www.w3.org/2000/svg"></svg> `;
6 changes: 3 additions & 3 deletions blocks/CloudImageEditor/src/EditorButtonControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export class EditorButtonControl extends Block {

this.sub('active', (active) => {
this.className = classNames({
active: active,
not_active: !active,
'uc-active': active,
'uc-not_active': !active,
});
});

Expand All @@ -39,6 +39,6 @@ export class EditorButtonControl extends Block {
EditorButtonControl.template = /* HTML */ `
<button type="button" role="option">
<lr-icon set="@name: icon;"></lr-icon>
<div class="title" ref="title-el">{{title}}</div>
<div class="uc-title" ref="title-el">{{title}}</div>
</button>
`;
4 changes: 2 additions & 2 deletions blocks/CloudImageEditor/src/EditorFilterControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
initCallback() {
super.initCallback();

this.$['on.click'] = (e) => {

Check warning on line 76 in blocks/CloudImageEditor/src/EditorFilterControl.js

View workflow job for this annotation

GitHub Actions / build

'e' is defined but never used
if (!this.$.active) {
this.$['*sliderEl'].setOperation(this._operation, this._filter);
this.$['*sliderEl'].apply();
Expand All @@ -100,7 +100,7 @@
this._originalUrl = originalUrl;

if (this.$.isOriginal) {
this.ref['icon-el'].classList.add('original-icon');
this.ref['icon-el'].classList.add('uc-original-icon');
} else {
this._observer.observe(this);
}
Expand Down Expand Up @@ -149,7 +149,7 @@

EditorFilterControl.template = /* HTML */ `
<button type="button" role="option">
<div class="preview" ref="preview-el"></div>
<div class="uc-preview" ref="preview-el"></div>
<lr-icon ref="icon-el" set="@name: icon; @size: iconSize;"></lr-icon>
</button>
`;
14 changes: 7 additions & 7 deletions blocks/CloudImageEditor/src/EditorImageCropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ export class EditorImageCropper extends Block {
this._transitionToImage();
setTimeout(() => {
this.className = classNames({
active_from_viewer: fromViewer,
active_from_editor: !fromViewer,
inactive_to_editor: false,
'uc-active_from_viewer': fromViewer,
'uc-active_from_editor': !fromViewer,
'uc-inactive_to_editor': false,
});
});
}
Expand Down Expand Up @@ -413,9 +413,9 @@ export class EditorImageCropper extends Block {
this._transitionToCrop();

this.className = classNames({
active_from_viewer: false,
active_from_editor: false,
inactive_to_editor: true,
'uc-active_from_viewer': false,
'uc-active_from_editor': false,
'uc-inactive_to_editor': true,
});

this.ref['frame-el'].toggleThumbs(false);
Expand Down Expand Up @@ -546,6 +546,6 @@ export class EditorImageCropper extends Block {
}

EditorImageCropper.template = /* HTML */ `
<canvas class="canvas" ref="canvas-el"></canvas>
<canvas class="uc-canvas" ref="canvas-el"></canvas>
<lr-crop-frame ref="frame-el"></lr-crop-frame>
`;
29 changes: 16 additions & 13 deletions blocks/CloudImageEditor/src/EditorImageFader.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class EditorImageFader extends Block {
/** @private */
this._addKeypointDebounced = debounce(this._addKeypoint.bind(this), 600);

this.classList.add('inactive_to_cropper');
this.classList.add('uc-inactive_to_cropper');
}

/**
Expand Down Expand Up @@ -201,7 +201,7 @@ export class EditorImageFader extends Block {
image.addEventListener('load', stop, { once: true });
image.addEventListener('error', stop, { once: true });
keypoint.image = image;
image.classList.add('fader-image');
image.classList.add('uc-fader-image');

image.addEventListener(
'load',
Expand Down Expand Up @@ -264,7 +264,7 @@ export class EditorImageFader extends Block {
/** @private */
_createPreviewImage() {
let image = new Image();
image.classList.add('fader-image', 'fader-image--preview');
image.classList.add('uc-fader-image', 'uc-fader-image--preview');
image.style.opacity = '0';
return image;
}
Expand Down Expand Up @@ -298,7 +298,7 @@ export class EditorImageFader extends Block {
this._container = container;
this._keypoints.forEach((kp, idx) => {
let kpImage = images[idx];
kpImage.classList.add('fader-image');
kpImage.classList.add('uc-fader-image');
kp.image = kpImage;
this._container.appendChild(kpImage);
});
Expand Down Expand Up @@ -354,10 +354,11 @@ export class EditorImageFader extends Block {
if (image.src === src) {
image.style.opacity = '1';
image.style.transform = 'scale(1)';

this.className = classNames({
active_from_viewer: this._fromViewer,
active_from_cropper: !this._fromViewer,
inactive_to_cropper: false,
'uc-active_from_viewer': this._fromViewer,
'uc-active_from_cropper': !this._fromViewer,
'uc-inactive_to_cropper': false,
});
return;
}
Expand All @@ -372,10 +373,11 @@ export class EditorImageFader extends Block {
if (image) {
image.style.opacity = '1';
image.style.transform = 'scale(1)';

this.className = classNames({
active_from_viewer: this._fromViewer,
active_from_cropper: !this._fromViewer,
inactive_to_cropper: false,
'uc-active_from_viewer': this._fromViewer,
'uc-active_from_cropper': !this._fromViewer,
'uc-inactive_to_cropper': false,
});
}
},
Expand Down Expand Up @@ -432,10 +434,11 @@ export class EditorImageFader extends Block {
if (this._previewImage) {
this._previewImage.style.transform = 'scale(1)';
}

this.className = classNames({
active_from_viewer: false,
active_from_cropper: false,
inactive_to_cropper: true,
'uc-active_from_viewer': false,
'uc-active_from_cropper': false,
'uc-inactive_to_cropper': true,
});
this.addEventListener(
'transitionend',
Expand Down
Loading
Loading