Skip to content

Commit aec1740

Browse files
committed
Internal: Updated css, circle crop and slider
1 parent ac1fb80 commit aec1740

30 files changed

+718
-758
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Changed the CSS to facilitate future modifications, with variables and new icons. @humanaice
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated Slider to make it more simple and intuitive. @humanaice
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed circle crop. @humanaice

packages/volto-image-editor/src/components/ImageEditor/Editor/ImageEditor.scss

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,67 @@
11
@import '~react-advanced-cropper/dist/style.css';
2+
@import '../../../theme/variables';
23
@import '../../../theme/constants';
34

45
.image-editor {
56
width: 100%;
6-
border: solid 1px #2b2a30;
7-
color: $theme-color;
7+
color: $settings-header-color;
8+
89
&__preview {
910
position: absolute;
10-
top: 20px;
11-
left: 20px;
11+
top: $image-editor-spacing-xl;
12+
left: $image-editor-spacing-xl;
1213
width: 45px;
1314
height: 45px;
14-
border: solid 1px #2b2a30;
15-
border-radius: 50%;
16-
background: black;
15+
border: solid 1px $image-editor-border-color;
16+
border-radius: $image-editor-border-radius-circle;
17+
background: $settings-header-bg;
1718
}
19+
1820
&__cropper {
1921
position: relative;
2022
display: flex;
2123
height: 500px;
2224
max-height: 100vh;
2325
align-items: center;
2426
justify-content: center;
25-
background: #0f0e13;
27+
background: $color-gray-dark;
2628
}
29+
2730
&__slider {
2831
position: absolute;
29-
bottom: 20px;
32+
bottom: $image-editor-spacing-xl;
3033
left: 50%;
3134
width: 100%;
3235
transform: translateX(-50%);
3336
}
37+
3438
&__cropper-overlay {
35-
transition: 0.5s;
39+
transition: $image-editor-transition-slow;
40+
3641
&--faded {
37-
color: rgba(black, 0.9);
42+
color: $image-editor-bg-overlay;
3843
}
3944
}
45+
4046
&__service {
4147
position: absolute;
4248
left: -100%;
4349
pointer-events: none;
4450
}
51+
4552
&__reset-button {
4653
position: absolute;
47-
top: 20px;
48-
right: 20px;
49-
background: rgba(white, 0.1);
54+
top: $image-editor-spacing-xl;
55+
right: $image-editor-spacing-xl;
56+
background: $editor-button-bg;
57+
color: $editor-button-color;
58+
5059
&:hover {
51-
background: rgba(white, 0.2);
52-
fill: $theme-color;
60+
background: $editor-button-bg-hover;
61+
color: $editor-button-color-hover;
62+
fill: $editor-button-color-hover;
5363
}
64+
5465
&--hidden {
5566
opacity: 0;
5667
visibility: hidden;

packages/volto-image-editor/src/components/ImageEditor/Editor/ImageEditor.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,35 @@ const ImageEditor = ({ src, onImageSave, onCancel }) => {
121121
if (canvas) {
122122
let finalCanvas = canvas;
123123

124+
if (imageSettings.stencilType === 'circle') {
125+
const circleCanvas = document.createElement('canvas');
126+
const ctx = circleCanvas.getContext('2d');
127+
128+
if (ctx) {
129+
circleCanvas.width = canvas.width;
130+
circleCanvas.height = canvas.height;
131+
132+
const centerX = canvas.width / 2;
133+
const centerY = canvas.height / 2;
134+
const radius = Math.min(canvas.width, canvas.height) / 2;
135+
136+
ctx.beginPath();
137+
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
138+
ctx.closePath();
139+
ctx.clip();
140+
141+
ctx.drawImage(canvas, 0, 0);
142+
143+
finalCanvas = circleCanvas;
144+
}
145+
}
146+
124147
if (imageSettings.maxWidth || imageSettings.maxHeight) {
125148
const tempCanvas = document.createElement('canvas');
126149
const ctx = tempCanvas.getContext('2d');
127150

128151
if (ctx) {
129-
let { width, height } = canvas;
152+
let { width, height } = finalCanvas;
130153

131154
if (imageSettings.maxWidth && width > imageSettings.maxWidth) {
132155
const ratio = imageSettings.maxWidth / width;
@@ -144,7 +167,7 @@ const ImageEditor = ({ src, onImageSave, onCancel }) => {
144167

145168
tempCanvas.width = width;
146169
tempCanvas.height = height;
147-
ctx.drawImage(canvas, 0, 0, width, height);
170+
ctx.drawImage(finalCanvas, 0, 0, width, height);
148171
finalCanvas = tempCanvas;
149172
}
150173
}

packages/volto-image-editor/src/components/ImageEditor/Wrapper/ImageEditorWrapper.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
@import '../../../theme/variables';
2+
13
.react-aria-ModalOverlay {
24
.react-aria-Modal.image-cropper-modal {
35
max-width: 70vw;
46
border: 0;
5-
background-color: black;
7+
background-color: $settings-header-bg;
8+
69
.react-aria-Dialog {
710
display: flex;
811
align-items: center;
Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,57 @@
1+
@import '../../../../theme/variables';
12
@import '../../../../theme/mixins';
23

34
.image-editor-button {
45
display: flex;
5-
width: 46px;
6-
height: 46px;
6+
width: $image-editor-button-size-desktop;
7+
height: $image-editor-button-size-desktop;
78
align-items: center;
89
justify-content: center;
910
padding: 0;
1011
border: none;
11-
border-radius: 50%;
12-
background: transparent;
13-
color: currentColor;
12+
border-radius: $image-editor-button-border-radius;
13+
background: $nav-button-bg;
14+
color: $nav-button-color;
1415
cursor: pointer;
15-
fill: #88888b;
16+
fill: $nav-button-color;
1617
outline: none;
17-
transition: 0.5s;
18-
&--active {
19-
background: rgba(white, 0.03);
20-
fill: currentColor;
21-
}
18+
transition: $image-editor-transition-slow;
19+
2220
&:hover,
2321
&:focus {
24-
background: rgba(white, 0.03);
22+
background: $nav-button-bg-hover;
23+
color: $nav-button-color-hover;
24+
fill: $nav-button-color-hover;
25+
}
26+
27+
&--active,
28+
&--active:hover,
29+
&--active:focus {
30+
background: $nav-button-bg-active;
31+
color: $nav-button-color-active;
32+
fill: $nav-button-color-active;
33+
}
34+
35+
&--close {
36+
color: $nav-button-close-color;
37+
fill: $nav-button-close-color;
2538
}
39+
40+
&--editor {
41+
background: $editor-button-bg;
42+
color: $editor-button-color;
43+
fill: $editor-button-color;
44+
45+
&:hover,
46+
&:focus {
47+
background: $editor-button-bg-hover;
48+
color: $editor-button-color-hover;
49+
fill: $editor-button-color-hover;
50+
}
51+
}
52+
2653
@include small-mobile() {
27-
width: 32px;
28-
height: 32px;
54+
width: $image-editor-button-size-mobile;
55+
height: $image-editor-button-size-mobile;
2956
}
3057
}
Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,60 @@
1+
@import '../../../../theme/variables';
12
@import '../../../../theme/mixins';
23

34
.image-editor-navigation {
45
display: flex;
56
height: 100%;
67
align-items: center;
78
justify-content: space-between;
8-
padding: 16px;
9-
border-top: solid 1px #2b2a30;
10-
background: #1b1a21;
9+
padding: $image-editor-spacing-lg;
10+
border-top: solid 1px $image-editor-border-color;
11+
background: $settings-header-bg;
12+
1113
&__button {
1214
&--disabled {
1315
cursor: not-allowed;
14-
opacity: 0.4;
16+
opacity: $image-editor-opacity-disabled;
1517
pointer-events: none;
1618
}
1719
}
1820

1921
&__reset-rotation {
20-
border-left: 1px solid rgba(white, 0.1);
21-
margin-left: 12px;
22+
margin-left: $image-editor-spacing-md;
2223
}
24+
2325
&__buttons {
2426
display: flex;
2527
flex-wrap: wrap;
2628
align-items: center;
2729
justify-content: center;
28-
gap: 8px;
30+
gap: $image-editor-spacing-sm;
31+
32+
svg {
33+
width: $image-editor-icon-size-desktop;
34+
height: $image-editor-icon-size-desktop;
35+
}
36+
37+
@include small-mobile() {
38+
svg {
39+
width: $image-editor-icon-size-mobile;
40+
height: $image-editor-icon-size-mobile;
41+
}
42+
}
2943
}
44+
45+
&__action-buttons {
46+
display: flex;
47+
flex-direction: row;
48+
align-items: center;
49+
gap: $image-editor-spacing-xl;
50+
}
51+
3052
&__upload-input {
3153
display: none;
3254
}
3355

3456
@include small-mobile() {
35-
padding-right: 8px;
36-
padding-left: 8px;
57+
padding-right: $image-editor-spacing-sm;
58+
padding-left: $image-editor-spacing-sm;
3759
}
3860
}

packages/volto-image-editor/src/components/ImageEditor/components/Navigation/Navigation.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,17 @@ export const Navigation: FC<Props> = ({
139139
<HueIcon />
140140
</Button>
141141
</div>
142-
<Button
143-
className={'image-editor-navigation__button cancel'}
144-
onClick={onCancel}
145-
>
146-
<CancelIcon />
147-
</Button>
148-
<Button className={'image-editor-navigation__button'} onClick={onSave}>
149-
<SaveIcon />
150-
</Button>
142+
<div className="image-editor-navigation__action-buttons">
143+
<Button
144+
className={'image-editor-navigation__button cancel'}
145+
onClick={onCancel}
146+
>
147+
<CancelIcon />
148+
</Button>
149+
<Button className={'image-editor-navigation__button'} onClick={onSave}>
150+
<SaveIcon />
151+
</Button>
152+
</div>
151153
</div>
152154
);
153155
};

0 commit comments

Comments
 (0)