Skip to content

Commit

Permalink
fix: ghost styles while dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Oct 27, 2024
1 parent f5c0432 commit 90e29af
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/demo/sass/demo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ body {
display: inline-block;
width: 224px;
height: 150px;
mask-image: url("assets/img/formeo-logo.svg");
mask-image: url("/assets/img/formeo-logo.svg");
mask-repeat: no-repeat;
background-image: linear-gradient(
-60deg,
Expand Down
6 changes: 5 additions & 1 deletion src/lib/js/components/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export default class Data {
const callbackPath = Array.isArray(path) ? path.join('.') : path
const callBackGroups = Object.keys(this.setCallbacks).filter(setKey => new RegExp(setKey).test(callbackPath))
const cbArgs = { newVal, oldVal, path }
callBackGroups.forEach(cbGroup => this.setCallbacks[cbGroup].forEach(cb => cb(cbArgs)))
for (const cbGroup of callBackGroups) {
for (const cb of this.setCallbacks[cbGroup]) {
cb(cbArgs)
}
}

if (!this.disableEvents) {
const change = this.getChangeType(oldVal, newVal)
Expand Down
24 changes: 7 additions & 17 deletions src/lib/js/components/rows/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ export default class Row extends Component {
* @return {Object} edit window dom config for Row
*/
get editWindow() {
const _this = this

const fieldsetInput = {
tag: 'input',
id: _this.id + '-fieldset',
id: `${this.id}-fieldset`,
attrs: {
type: 'checkbox',
checked: this.get('config.fieldset'),
Expand Down Expand Up @@ -118,11 +116,11 @@ export default class Row extends Component {
attrs: {
type: 'text',
ariaLabel: 'Legend for fieldset',
value: _this.get('config.legend'),
value: this.get('config.legend'),
placeholder: 'Legend',
},
action: {
input: ({ target: { value } }) => _this.set('config.legend', value),
input: ({ target: { value } }) => this.set('config.legend', value),
},
className: '',
}
Expand Down Expand Up @@ -186,9 +184,9 @@ export default class Row extends Component {
return
}

const width = parseFloat((100 / columns.length).toFixed(1)) / 1
const width = Number.parseFloat((100 / columns.length).toFixed(1)) / 1

columns.forEach(column => {
for (const column of columns) {
column.removeClasses(bsColRegExp)
const colDom = column.dom
const newColWidth = numToPercent(width)
Expand All @@ -201,7 +199,7 @@ export default class Row extends Component {
column.refreshFieldPanels()
}, ANIMATION_SPEED_FAST)
document.dispatchEvent(events.columnResized)
})
}

this.updateColumnPreset()
}
Expand Down Expand Up @@ -283,7 +281,6 @@ export default class Row extends Component {
* @return {Object} columnPresetControlConfig
*/
get columnPresetControlConfig() {
const _this = this
const layoutPreset = {
tag: 'select',
attrs: {
Expand All @@ -293,14 +290,7 @@ export default class Row extends Component {
action: {
change: ({ target }) => {
const { value } = target

// forEach(target.children, option => {
// option.selected = option.value === value
// })
// if (value !== 'custom') {
// removeCustomOption(this.dom)
_this.setColumnWidths(value)
// }
this.setColumnWidths(value)
},
},
options: this.getColumnPresetOptions,
Expand Down
4 changes: 3 additions & 1 deletion src/lib/js/components/stages/stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export default class Stage extends Component {
disabled: false,
onAdd: this.onAdd.bind(this),
onRemove: this.onRemove.bind(this),
onStart: () => (Stages.active = this),
onStart: () => {
Stages.active = this
},
onSort: this.onSort.bind(this),
draggable: `.${ROW_CLASSNAME}`,
handle: '.item-move',
Expand Down
9 changes: 9 additions & 0 deletions src/lib/sass/components/_column.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@
display: none;
}
}

&.sortable-ghost {
background-color: color.$column-highlight-color;
box-shadow: 0 0 0 1px color.$column-outline-color;
* {
opacity: 0;
}
}
}

// this is column styleing in the row edit window
Expand Down Expand Up @@ -164,6 +172,7 @@

.column-moving {
background-color: color.$column-highlight-color;

.action-btn-wrap {
button {
background-color: color.$column-highlight-color;
Expand Down
8 changes: 8 additions & 0 deletions src/lib/sass/components/_field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
&.field-type-hidden {
border: 1px dashed color.$gray-lighter;
}

&.sortable-ghost {
background-color: color.$field-highlight-color;
box-shadow: 0 0 0 1px color.$field-outline-color;
* {
opacity: 0;
}
}
}

.field-tag {
Expand Down
10 changes: 9 additions & 1 deletion src/lib/sass/components/_row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,18 @@
display: none;
}
}

&.sortable-ghost {
background-color: color.$row-highlight-color;
box-shadow: 0 0 0 1px color.$row-outline-color;
* {
opacity: 0;
}
}
}

.row-moving {
background-color: color.$row-highlight-color;
background-color: color.$row-highlight-color !important;
.action-btn-wrap {
button {
background-color: color.$row-highlight-color;
Expand Down
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const libConfig = {
const demoConfig = {
...sharedConfig,
root: 'src/demo',
base: '',
base: '/',
resolve: {
alias: {
'formeo': resolve(__dirname, 'src/lib/js/index.js'),
Expand Down

0 comments on commit 90e29af

Please sign in to comment.