Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeSimoes committed Sep 27, 2024
1 parent acaf728 commit 59fe2fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
20 changes: 7 additions & 13 deletions blocks/grid/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ export default class Grid extends ComponentBase {
attributesValues = {
all: {
grid: {
// set props directly as css variables instead of data-attributes
template: {
columns: '1fr 1fr 1fr',
rows: '1fr',
},
gap: '20px',
},
},
Expand All @@ -30,16 +25,15 @@ export default class Grid extends ComponentBase {

// for backwards compatibility
applyData(data) {
if (data.columns) {
// data.columns is deprecated, use grid-template-columns
if (data.template) {
if (!data.template.columns) {
data.template.columns = data.columns;
['columns', 'rows'].forEach((key) => {
if (data[key]) {
if (data.template) {
data.template[key] = data[key];
} else {
data.template = { [key]: data[key] };
}
} else {
data.template = { columns: data.columns };
}
}
});
this.applyGrid(data);
}

Expand Down
25 changes: 12 additions & 13 deletions scripts/component-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,27 +179,28 @@ export default class ComponentBase extends HTMLElement {
inicial.unshift(); // remove the component name
this.initialAttributesValues = classToFlat(inicial.splice(1));
const initialAttributesValues = this.initialAttributesValues || { all: { data: {} } };
if (!this.dataAttributesKeys.length) {
if (this.dataAttributesKeys && !this.dataAttributesKeys.length) {
this.setDataAttributesKeys();
} else {
this.dataAttributesKeys = this.dataAttributesKeys || [];
}
// this.dataAttributesKeys.forEach(({ noData, noDataCamelCase }) => {
// const value = this.dataset[noDataCamelCase];
this.dataAttributesKeys.forEach(({ noData, noDataCamelCase }) => {
const value = this.dataset[noDataCamelCase];

// if (typeof value === 'undefined') return {};
// const initialValue = unFlat({ [noData]: value });
// if (initialAttributesValues.all && initialAttributesValues.all.data) {
// initialAttributesValues.all.data = deepMerge({}, initialAttributesValues.all.data, initialValue);
// }
// return initialAttributesValues;
// });
if (typeof value === 'undefined') return {};
const initialValue = unFlat({ [noData]: value });
if (initialAttributesValues.all && initialAttributesValues.all.data) {
initialAttributesValues.all.data = deepMerge({}, initialAttributesValues.all.data, initialValue);
}
return initialAttributesValues;
});

this.attributesValues = deepMerge(
{},
this.attributesValues,
this.initOptions?.attributesValues || {},
initialAttributesValues,
);
console.log(this.attributesValues);
}

async connectComponent() {
Expand Down Expand Up @@ -287,8 +288,6 @@ export default class ComponentBase extends HTMLElement {
// for anything else set them flatten as they come from from external config
const configs = unFlat(await externalConfig.getConfig(this.componentName, values.config));

console.log('external', configs);

if (this.overrideExternalConfig) {
// Used for preview functionality
values = deepMerge({}, configs, this.attributesValues, values);
Expand Down

0 comments on commit 59fe2fa

Please sign in to comment.