Skip to content

Commit

Permalink
refactor(image): [image] refactor the image theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Youyou-smiles committed Oct 11, 2024
1 parent feea189 commit 277bcae
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 72 deletions.
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/image/keep-style.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test('测试样式属性保持', async ({ page }) => {
await expect(viewerImage).toHaveCount(1)
await expect(canvas).toHaveCount(1)
await expect(mask).toHaveCSS('position', 'absolute')
await expect(mask).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.5)')
await expect(mask).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.08)')
await expect(canvas).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, 0)')

// 点击缩小
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/image/preview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test('测试图片预览大图', async ({ page }) => {
await expect(viewerImage).toHaveCount(1)
await expect(canvas).toHaveCount(1)
await expect(mask).toHaveCSS('position', 'absolute')
await expect(mask).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.5)')
await expect(mask).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.08)')
await expect(canvas).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, 0)')

// 点击缩小
Expand Down
70 changes: 36 additions & 34 deletions packages/theme/src/image-viewer/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
.component-css-vars-image-viewer();

&__wrapper {
background: var(--ti-image-viewer-mask-wrap-bg-color);
background: none;
position: fixed;
top: 0;
right: 0;
Expand All @@ -35,30 +35,32 @@
align-items: center;
justify-content: center;
border-radius: 50%;
opacity: var(--ti-image-viewer-btn-opacity);
opacity: 1;
box-sizing: border-box;
.user-select(none);

svg {
fill: var(--ti-image-viewer-text-color);
width: 20px;
height: 20px;
fill: var(--tv-Image-viewer-text-color);
}
}

&__close {
top: var(--ti-image-viewer-close-top);
right: var(--ti-image-viewer-close-right);
width: var(--ti-image-viewer-close-width);
height: var(--ti-image-viewer-close-height);
font-size: var(--ti-image-viewer-close-font-size);
background-color: var(--ti-image-viewer-close-bg-color);
top: 32px;
right: 32px;
width: 40px;
height: 40px;
font-size: var(--tv-Image-viewer-close-font-size);
background-color: var(--tv-Image-viewer-close-bg-color);

&:hover {
cursor: pointer;
background-color: var(--ti-image-viewer-close-bg-color-hover);
background-color: #606266;
}
}

&__canvas {
&__canvas {
width: 100%;
height: 100%;
display: flex;
Expand All @@ -68,29 +70,26 @@

&__actions {
left: 50%;
bottom: var(--ti-image-viewer-actions-bottom);
bottom: 32px;
transform: translateX(-50%);
width: var(--ti-image-viewer-actions-width);
height: var(--ti-image-viewer-actions-height);
padding: 0 23px;
background-color: var(--ti-image-viewer-close-bg-color);
border-radius: var(--ti-image-viewer-actions-border-radius);
width: 248px;
height: var(--tv-Image-viewer-actions-height);
padding: 10px 24px;
background-color: var(--tv-Image-viewer-close-bg-color);
border-radius: var(--tv-Image-viewer-actions-border-radius);
}

&__actions-inner {
width: 100%;
height: 100%;
text-align: justify;
cursor: default;
font-size: var(--ti-image-viewer-actions-inner-font-size);
display: flex;
align-items: center;
justify-content: var(--ti-image-viewer-actions-inner-justify-content);
justify-content: space-around;

svg {
fill: var(--ti-image-viewer-actions-inner-text-color);
margin-right: var(--ti-image-viewer-actions-icon-margin-right);
font-size: var(--ti-image-viewer-actions-icon-size);
fill: var(--tv-Image-viewer-actions-inner-text-color);
margin-right: var(--tv-Image-viewer-actions-icon-margin-right);

&:hover {
cursor: pointer;
Expand All @@ -99,38 +98,41 @@
}

&__actions-divider {
display: var(--ti-image-viewer-actions-divider-display);
display: inline-block;
}

&__actions-count {
font-size: var(--ti-image-viewer-actions-count-font-size);
display: inline-block;
width: 20px;
height: 20px;
line-height: 20px;
font-size: var(--tv-Image-viewer-actions-count-font-size);
color: #fff;
position: relative;
margin-left: var(--ti-image-viewer-actions-count-margin-left);
}

&__next,
&__prev {
top: 50%;
width: var(--ti-image-viewer-next-width);
height: var(--ti-image-viewer-next-height);
font-size: var(--ti-image-viewer-next-font-size);
background-color: var(--ti-image-viewer-close-bg-color);
width: var(--tv-Image-viewer-next-width);
height: var(--tv-Image-viewer-next-height);
font-size: var(--tv-Image-viewer-next-font-size);
background-color: var(--tv-Image-viewer-close-bg-color);

&:hover {
cursor: pointer;
background-color: var(--ti-image-viewer-close-bg-color-hover);
background-color: #606266;
}
}

&__prev {
transform: translateY(-50%);
left: var(--ti-image-viewer-prev-left);
left: var(--tv-Image-viewer-prev-left);
}

&__next {
transform: translateY(-50%);
right: var(--ti-image-viewer-next-right);
right: var(--tv-Image-viewer-next-right);
text-indent: 2px;
}

Expand All @@ -140,6 +142,6 @@
height: 100%;
top: 0;
left: 0;
background: var(--ti-image-viewer-mask-bg-color);
background: rgba(0,0,0,0.08);
}
}
42 changes: 14 additions & 28 deletions packages/theme/src/image-viewer/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,18 @@
*/

.component-css-vars-image-viewer() {
--ti-image-viewer-text-color: var(--ti-common-color-light, #ffffff);
--ti-image-viewer-actions-inner-text-color: var(--ti-common-color-light, #ffffff);
--ti-image-viewer-close-font-size: var(--ti-common-font-size-4, 20px);
--ti-image-viewer-close-bg-color: rgba(0,0,0,0.10);
--ti-image-viewer-close-top: 40px;
--ti-image-viewer-close-right: 40px;
--ti-image-viewer-close-width: 40px;
--ti-image-viewer-close-height: 40px;
--ti-image-viewer-close-bg-color-hover: #606266;
--ti-image-viewer-actions-border-radius: 22px;
--ti-image-viewer-actions-inner-font-size: 23px;
--ti-image-viewer-actions-width: calc(var(--ti-common-size-50x, 200px) + var(--ti-common-size-12x));
--ti-image-viewer-actions-height: var(--ti-common-size-10x, 40px);
--ti-image-viewer-actions-bottom: var(--ti-common-size-8x, 32px);
--ti-image-viewer-actions-inner-justify-content: space-around;
--ti-image-viewer-next-font-size: var(--ti-common-font-size-5, 24px);
--ti-image-viewer-next-width: 44px;
--ti-image-viewer-next-height: 44px;
--ti-image-viewer-mask-wrap-bg-color: none;
--ti-image-viewer-btn-opacity: 1;
--ti-image-viewer-mask-bg-color: var(--ti-common-border-color-transparent-8, var(--ti-base-bg-color-transparent-8));
--ti-image-viewer-actions-icon-margin-right: var(--ti-common-size-0, 0px);
--ti-image-viewer-actions-icon-size: var(--ti-common-font-size-2, 16px);
--ti-image-viewer-actions-count-font-size: var(--ti-common-font-size-1, 14px);
--ti-image-viewer-actions-count-margin-left: var(--ti-common-size-0, 0px);
--ti-image-viewer-actions-divider-display: none;
--ti-image-viewer-prev-left: var(--ti-common-size-8x, 32px);
--ti-image-viewer-next-right: var(--ti-common-size-8x, 32px);
--tv-Image-viewer-text-color: var(--tv-color-success-text-white);
--tv-Image-viewer-actions-inner-text-color: var(--tv-color-success-text-white);
--tv-Image-viewer-close-font-size: var(--tv-font-size-xxl);
--tv-Image-viewer-close-bg-color: var(--tv-color-bg-control-unactive);
--tv-Image-viewer-actions-border-radius: var(--tv-border-radius-round);
--tv-Image-viewer-actions-height: var(--tv-size-height-lg);
--tv-Image-viewer-next-font-size: calc(var(--tv-size-base) * 6);
--tv-Image-viewer-next-width: var(--tv-size-height-lg);
--tv-Image-viewer-next-height: var(--tv-size-height-lg);
--tv-Image-viewer-btn-opacity: 1;
--tv-Image-viewer-actions-icon-margin-right: var(--tv-space-xl);
--tv-Image-viewer-actions-count-font-size: var(--tv-font-size-md);
--tv-Image-viewer-prev-left: calc(var(--tv-space-base) * 8);
--tv-Image-viewer-next-right: calc(var(--tv-space-base) * 8);
}
4 changes: 2 additions & 2 deletions packages/theme/src/image/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@

&-text {
margin-top: 4px;
display: var(--ti-image-error-display);
display: inline-block;
}

& > .tiny-svg {
font-size: 16px;
display: var(--ti-image-error-display);
display: inline-block;
}
}

Expand Down
Loading

0 comments on commit 277bcae

Please sign in to comment.