Skip to content

Commit

Permalink
fix: nested styles prevent external controls
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Feb 24, 2020
1 parent b0bac9d commit 611cfa3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/js/components/controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ export class Controls {
const _this = this
const groupedFields = this.groupElements()
const formActions = this.formActions()
_this.panels = new Panels({ panels: groupedFields, type: 'controls' })
const groupsWrapClasses = ['control-groups', 'panels-wrap', `panel-count-${groupedFields.length}`]
_this.panels = new Panels({ panels: groupedFields, type: 'controls', displayType: 'slider' })
const groupsWrapClasses = ['control-groups', 'formeo-panels-wrap', `panel-count-${groupedFields.length}`]
const groupsWrap = dom.create({
className: groupsWrapClasses,
content: _this.panels.children,
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/fields/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export default class Field extends Component {
const allowedPanels = panelOrder.filter(panelName => !noPanels.includes(panelName))

const fieldEdit = {
className: ['field-edit', 'slide-toggle', 'panels-wrap'],
className: ['field-edit', 'slide-toggle', 'formeo-panels-wrap'],
}

allowedPanels.forEach(panelName => {
Expand Down Expand Up @@ -252,7 +252,7 @@ export default class Field extends Component {
prevData.id = `prev-${this.id}`

if (this.data.config.editableContent) {
prevData.attrs = Object.assign({}, prevData.attrs, {contenteditable: true})
prevData.attrs = Object.assign({}, prevData.attrs, { contenteditable: true })
}

const fieldPreview = {
Expand Down
43 changes: 4 additions & 39 deletions src/js/components/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import i18n from 'mi18n'
import Sortable from 'sortablejs'
import h, { indexOfNode } from '../common/helpers'
import dom from '../common/dom'
// import Fields from './fields'

const defaults = {
type: 'field',
Expand All @@ -27,11 +26,8 @@ export default class Panels {
this.panels = panels.childNodes
this.currentPanel = _this.panels[0]
this.nav = _this.navActions()
// if (_this.opts.type === 'field') {
// setTimeout(_this.setPanelsHeight.bind(_this), 100)
// }

this.panelDisplay = 'slider'
this.panelDisplay = this.opts.displayType || 'slider'

return {
children: [_this.labels, panels],
Expand All @@ -50,8 +46,9 @@ export default class Panels {
const panelsWrap = this.panelsWrap
const column = panelsWrap.parentElement.parentElement
const width = parseInt(dom.getStyle(column, 'width'))
const isTabbed = width > 390
this.panelDisplay = isTabbed ? 'tabbed' : 'slider'
const autoDisplayType = width > 390 ? 'tabbed' : 'slider'
this.panelDisplay = this.opts.displayType || autoDisplayType
const isTabbed = this.panelDisplay === 'tabbed'
panelsWrap.parentElement.classList.toggle('tabbed-panels', isTabbed)
const panelStyle = panelsWrap.style
const activePanelHeight = dom.getStyle(this.currentPanel, 'height')
Expand All @@ -62,27 +59,6 @@ export default class Panels {
return activePanelHeight
}

/**
* Set panel height so we can animate it with css
*/
// setPanelsHeight() {
// const field = Fields.get(this.opts.id).dom
// this.slideToggle = field.querySelector('.field-edit')

// // temp styles
// this.slideToggle.style.display = 'block'
// this.slideToggle.style.position = 'absolute'
// this.slideToggle.style.opacity = 0

// this.resizePanels()

// // reset styles
// this.slideToggle.style.display = 'none'
// this.slideToggle.style.position = 'relative'
// this.slideToggle.style.opacity = 1
// this.slideToggle.style.height = 'auto'
// }

/**
* Wrap a panel and make properties sortable
* if the panel belongs to a field
Expand Down Expand Up @@ -133,17 +109,6 @@ export default class Panels {
})
}

/**
* Save a fields' property
* @param {Object} group property group
* @return {Object} DOM node for updated property preview
*/
// propertySave(group) {
// const field = dom.fields.get(this.opts.id)
// data.save(group.editGroup, group, false)
// return field.instance.updatePreview()
// }

/**
* Panel navigation, tabs and arrow buttons for slider
* @return {Object} DOM object for panel navigation wrapper
Expand Down
3 changes: 2 additions & 1 deletion src/sass/components/_controls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@
&.prev-group {
border-top-left-radius: $border-radius;
border-bottom-left-radius: 0;
left: 0;
}
}
}

.panels-wrap {
.formeo-panels-wrap {
font-size: 0.85em;
line-height: 1.8em;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sass/components/_panels.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.panels-wrap {
.formeo-panels-wrap {
h5 {
margin: 0;
padding: 0.55em 0;
Expand Down
1 change: 0 additions & 1 deletion src/sass/components/_stage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
@import 'components/column';
@import 'components/field';
@import 'components/field-edit';
@import 'components/panels';

.highlight-component {
box-shadow: 0 0 space() 2px $brand-info;
Expand Down
4 changes: 3 additions & 1 deletion src/sass/formeo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@import 'base/mixins';
@import 'base/icons';
@import 'components/autocomplete';
@import 'components/panels';

.formeo-sprite {
display: none !important;
Expand All @@ -23,7 +24,6 @@
text-align: left;
@import 'components/component';
@import 'components/stage';
@import 'components/controls';

@import 'base/rtl';
}
Expand All @@ -33,6 +33,8 @@
}
}

@import 'components/controls';

.field-control {
@extend %field-control;

Expand Down

0 comments on commit 611cfa3

Please sign in to comment.