Skip to content

Commit

Permalink
use a single checkerboard component and fix it (#4844)
Browse files Browse the repository at this point in the history
* use a single shared checkerboard component to fix it in color field and palette

* changelog

* use color variables

* fix changelog

* adds transparency checkerboard to RT color control (#4850)

---------

Co-authored-by: Etienne Laurent <[email protected]>
Co-authored-by: Stuart Romanek <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2025
1 parent 7da11c1 commit 92114c9
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 108 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Field inputs inside an array modal can now be focused/tabbed via keyboard
* Fixes admin bar overlapping widget area add menu.
* Fixed the checkered background for gauging color transparency.

### Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class="apos-color__active-color"
:style="{ background: activeColor }"
/>
<Checkboard />
<AposColorCheckerboard />
</div>
</div>
<div v-if="!disableFields" class="apos-color__field">
Expand Down Expand Up @@ -97,7 +97,7 @@
class="apos-color__presets-color"
@click="handlePreset(c)"
>
<Checkboard />
<AposColorCheckerboard />
</div>
</template>
</div>
Expand All @@ -110,7 +110,6 @@ import editableInput from '../lib/AposColorEditableInput.vue';
import saturation from '../lib/AposColorSaturation.vue';
import hue from '../lib/AposColorHue.vue';
import alpha from '../lib/AposColorAlpha.vue';
import checkboard from '../lib/AposColorCheckerboard.vue';
const defaultOptions = { ...apos.modules['@apostrophecms/color-field'].defaultOptions };
Expand All @@ -120,8 +119,7 @@ export default {
Saturation: saturation,
Hue: hue,
Alpha: alpha,
EditableContent: editableInput,
Checkboard: checkboard
EditableContent: editableInput
},
mixins: [ colorMixin ],
props: {
Expand Down Expand Up @@ -296,10 +294,6 @@ export default {
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 15%), inset 0 0 4px rgb(0 0 0 / 25%);
}
.apos-color__color-wrap .apos-color__checkerboard {
background-size: auto;
}
.apos-color__field {
display: flex;
padding-top: 4px;
Expand Down Expand Up @@ -353,7 +347,7 @@ export default {
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 15%);
}
.apos-color__presets-color .apos-color__checkerboard {
.apos-color__presets-color {
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 15%);
border-radius: 3px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="apos-color__alpha">
<div class="apos-color__alpha-checkboard-wrap">
<Checkboard />
<AposColorCheckerboard />
</div>
<div class="apos-color__alpha-gradient" :style="{ background: gradientColor }" />
<div
Expand All @@ -19,13 +19,8 @@
</template>

<script>
import checkboard from './AposColorCheckerboard.vue';
export default {
name: 'AposColorAlpha',
components: {
Checkboard: checkboard
},
props: {
value: {
type: Object,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@click="click"
>
<template #label>
<AposColorCheckerboard class="apos-color-control__checkerboard" />
<AposIndicator icon="chevron-down-icon" />
</template>
</AposButton>
Expand Down Expand Up @@ -244,4 +245,15 @@ export default defineComponent({
justify-content: flex-end;
margin-top: 10px;
}
.apos-color-control__checkerboard {
z-index: $z-index-under;
position: absolute;
top: 1.5px;
left: 1.5px;
width: 12px;
height: 12px;
border-radius: 50%;
pointer-events: none;
}
</style>
5 changes: 3 additions & 2 deletions modules/@apostrophecms/ui/ui/apos/components/AposButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
class="apos-button__color-preview"
>
<span :style="colorStyle" class="apos-button__color-preview__swatch" />
<span class="apos-button__color-preview__checkerboard" />
<div class="apos-button__color-preview__checkerboard">
<AposColorCheckerboard />
</div>
</span>
<div class="apos-button__content">
<AposIndicator
Expand Down Expand Up @@ -358,7 +360,6 @@ export default {
.apos-button__color-preview__checkerboard {
z-index: $z-index-base;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMElEQVQ4T2N89uzZfwY8QFJSEp80A+OoAcMiDP7//483HTx//hx/Ohg1gIFx6IcBALl+VXknOCvFAAAAAElFTkSuQmCC');
}
.apos-button--small {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div class="apos-color__checkerboard" />
</template>

<script>
export default {
name: 'AposColorCheckerboard'
};
</script>

<style>
.apos-color__checkerboard {
background-image: repeating-conic-gradient(
var(--a-checker-board-gray) 0% 25%,
var(--a-checker-board-white) 0% 50%
);
background-size: 8px 8px;
height: 100%;
}
</style>
4 changes: 4 additions & 0 deletions modules/@apostrophecms/ui/ui/apos/scss/global/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
--a-spreadsheet: #2ecc71;
--a-pdf: #e74c3c;

// Checkerboard colors
--a-checker-board-white: #fff;
--a-checker-board-gray: #d3d3d3;

// Font-Family
--a-family-default: -apple-system, system-ui, "BlinkMacSystemFont", "Segoe UI",
"Roboto", "Helvetica", "Arial", sans-serif, "Apple Color Emoji",
Expand Down

0 comments on commit 92114c9

Please sign in to comment.