Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add support for sections in the Sections Mapping UI #406

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e68717e
chore(sm-import): preparation step: rename section like tokens to blo…
catalan-adobe Jul 22, 2024
3e7b5a5
fix(sm-import): save sections mapping data when changing fragment path
catalan-adobe Jul 22, 2024
1c30461
refactor(sm-import): wip disable handling of section mapping data for…
catalan-adobe Jul 22, 2024
628b52f
refactor(sm-import): wip move block level function to dedicated secti…
catalan-adobe Jul 22, 2024
3a56a2b
feat(sm-import): wip add basic level of support for new section ui el…
catalan-adobe Jul 22, 2024
6b4b01b
refactor(sm-import): rename section selection proxy token to block
catalan-adobe Jul 22, 2024
50a9cd7
feat(sm-import): implement section selection in fragment
catalan-adobe Jul 22, 2024
fe44d82
fix(sm-import): remove fragment selection
catalan-adobe Jul 22, 2024
3e26caf
feat(sm-import): wip option to add section metadata block to section …
catalan-adobe Jul 22, 2024
0f06b3b
fix(sm-import): clicking detected box add entry in selected section
catalan-adobe Jul 22, 2024
8939b08
fix(sm-import): alert messages for block addition to section
catalan-adobe Jul 22, 2024
a4849cb
style(sm-import): make section settings less visible by default
catalan-adobe Jul 22, 2024
c52af5d
feat(sm-import): move fragment path edition into action button + tooltip
catalan-adobe Jul 22, 2024
4d9f911
fix(sm-import): multiple minor ui fixes/improvements
catalan-adobe Jul 22, 2024
9d59f52
feat(sm-import): implement saving new data structure in local storage
catalan-adobe Jul 22, 2024
ff8cb6c
fix(sm-import): automatically map to header parser when adding a bloc…
catalan-adobe Jul 22, 2024
4e0c2a0
fix(sm-import): save sections mapping data when editing section metad…
catalan-adobe Jul 22, 2024
9d47f5e
feat(sm-import): read sections data from cache and parse it into ui e…
catalan-adobe Jul 22, 2024
d7aacdc
chore(sm-import): linting
catalan-adobe Jul 23, 2024
7747cd5
feat(sm-import): set ui elements from cache data
catalan-adobe Jul 23, 2024
7c69c74
chore(sm-import): remove unused function
catalan-adobe Jul 23, 2024
c13457f
fix(sm-import): add a section by default when adding a fragment
catalan-adobe Jul 23, 2024
a9d39d0
feat(sm-import): enable drag and drop blocks between sections
catalan-adobe Jul 23, 2024
716ae24
refactor(sm-import): move section metadata style property in tooltip …
catalan-adobe Jul 23, 2024
f7f06bd
fix(sm-import): save/get section metadata style property
catalan-adobe Jul 23, 2024
03b73d1
fix(sm-import): when adding a new fragment, auto select the added sin…
catalan-adobe Jul 23, 2024
49dc2a1
chore(sm-import): cleanup
catalan-adobe Jul 23, 2024
4dfc756
fix(sm-import): when clicking import button only save sections mappin…
catalan-adobe Jul 23, 2024
3c3ef55
feat(sm-import): adapt sections mapping import script and parsers to …
catalan-adobe Jul 23, 2024
dff085d
chore(sm-import): linting
catalan-adobe Jul 23, 2024
f35d6cd
fix(sm-import): re-enable md/html preview panels
catalan-adobe Jul 23, 2024
78a095e
fix(sm-import): when parsing header only add image as brand logo, no …
catalan-adobe Jul 24, 2024
102a42b
feat(sm-import): on page first detection, automatically select the fi…
catalan-adobe Jul 24, 2024
84e2081
chore(sm-import): cleanup
catalan-adobe Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 125 additions & 37 deletions css/fragment-mapping/fragment.mapping.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,62 +52,150 @@
gap: 1rem;

& .sm-fragment {
padding: 1rem;
border-left: 25px solid var(--spectrum-global-color-gray-100);
padding: .1rem;
border-top: 2px solid var(--spectrum-global-color-gray-100);

& .sm-fragment-content {
display: flex;
flex-direction: column;
gap: 1rem;
&:hover {
background-color: var(--spectrum-global-color-gray-75);
}

&.selected {
border-left-color: blueviolet;
}
& #sm-fragment-edit-path-btn {
margin-left: 5px;
position: relative;
top: .4rem;
right: .4rem;
float: inline-end;

& summary {
font-family: monospace;
fill: white;
cursor: pointer;
padding: 0.5rem;
margin-bottom: 0.5rem;
font-size: x-large;
pointer-events: auto;

& h2 {
margin: 0;
& sp-textfield {
width: 140px;
}
}

&::marker {
color: var(--spectrum-global-color-gray-100);
pointer-events: auto;
}
& details {
margin: .4rem;

& text {
& summary {
font-family: monospace;
fill: white;
cursor: pointer;
padding: 0.5rem;
margin-bottom: 0.5rem;
font-size: x-large;
pointer-events: auto;
}

& h2 {
margin: 0;
}

&::marker {
color: var(--spectrum-global-color-gray-100);
pointer-events: auto;
}

& text {
pointer-events: auto;
}
}
}

& #delete-frg {
position: relative;
top: 5px;
float: inline-end;
}

& .sm-frg-settings-wrapper {
& .sm-frg-sections-title {
display: flex;
gap: 1rem;
margin: 1rem 5rem;
}

& .sm-frg-sections-title {
& .sm-fragment-content {
display: flex;
flex-direction: column;
gap: 1rem;
padding-left: 1.4rem;
padding-right: 1.4rem;

& .sm-frg-sections-title {
padding-bottom: .2rem;
border-bottom: solid 2px var(--spectrum-global-color-gray-100);
}

& .sm-fragment-sections {
padding-left: 1rem;
padding-right: 1rem;
display: flex;
flex-direction: column;
gap: 1rem;

& #delete-section {
margin-left: 5px;
position: relative;
top: 1rem;
right: 1rem;
float: inline-end;
}

& #sm-frg-section-edit-style-btn {
margin-left: 5px;
position: relative;
top: 1rem;
right: 1rem;
float: inline-end;

& sp-textfield {
width: 140px;
}
}

& summary {
font-size: medium;
text-transform: uppercase;
}

& .sm-frg-section {
margin: .4rem;
border-left: 25px solid var(--spectrum-global-color-gray-100);

&.selected {
border-left-color: blueviolet;
}

& .sm-frg-section-settings-wrapper {
opacity: .25;
display: flex;
gap: 1rem;
}

& .sm-frg-section-settings-wrapper:hover {
opacity: 1;
}

& .sm-frg-section-content {
display: flex;
flex-direction: column;
gap: 1rem;
padding-left: 1.4rem;
padding-right: 1.4rem;

& .sm-frg-sections-title {
border-bottom: solid 1px var(--spectrum-global-color-gray-100);
}
}

& .sm-frg-section-blocks {
padding: .5rem;
border: 4px solid transparent;
}

& .sm-frg-section-blocks.dragover {
border: 4px dashed var(--spectrum-global-color-gray-600);
background-color: var(--spectrum-global-color-gray-200);
}
}
}
}

& .sm-frg-settings-container {
flex-grow: 1;
& #delete-frg {
margin-left: 5px;
position: relative;
top: .4rem;
right: .4rem;
float: inline-end;
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions import-fragments.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ <h3>Page preview</h3>
</sp-button-group>
</sp-theme>
</sp-tab-panel>
<sp-tab-panel value="import-markdown">
<div data-panel="source">
<div class="code">
<textarea id="import-markdown-source" rows="4" cols="10"></textarea>
</div>
</div>
</sp-tab-panel>
<sp-tab-panel value="import-html">
<div data-panel="source">
<div class="code">
<textarea id="import-transformed-html" rows="4" cols="10"></textarea>
</div>
</div>
</sp-tab-panel>

</sp-tabs>
</div>
</div>
Expand Down
76 changes: 53 additions & 23 deletions js/dist/spectrum-web-components.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/import/import.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import * as fragmentUI from '../sections-mapping/sm.ui.js';
import { buildTransformationRulesFromMapping } from './import.rules.js';
import TransformFactory from '../shared/transformfactory.js';
import { detectSections } from '../sections-mapping/utils.js';
import detectSections from '../sections-mapping/utils.js';
import { preparePagePreview } from '../express/free-mapping/preview-selectors.js';
import { getFragmentSectionsMappingData } from '../sections-mapping/import/sections-mapping.import.js';

Expand Down
20 changes: 10 additions & 10 deletions js/sections-mapping/import/parsers/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ export default function headerParser(el, { document, params, allMappings }) {
const containerEl = document.createElement('div');

const brandEl = document.createElement('div');
const bodyWidth = allMappings.sections[0].width;
const bodyWidth = allMappings.sections[0]?.blocks[0]?.width;
const originURL = new URL(params.originalURL).origin;

const brandLogoMapping = [
{
checkFn: (e) => e.querySelector('a > img'),
parseFn: (e, targetEl, x) => {
const parentEl = e.parentElement;
if (x < bodyWidth / 2) {
if (bodyWidth && x < bodyWidth / 2) {
targetEl.append(e);
parentEl.append(document.createElement('br'));
targetEl.append(parentEl);
return true;
}
return false;
},
},
{
checkFn: (e) => e.querySelector('picture + br + a, image + br + a'),
checkFn: (e) => e.querySelector('picture + br + a, img + br + a'),
parseFn: (e, targetEl, x) => {
if (x < bodyWidth / 2) {
targetEl.append(e);
if (bodyWidth && x < bodyWidth / 2) {
const imgEl = e.closest('picture, img');
if (imgEl) {
targetEl.append(imgEl);
}
return true;
}
return false;
Expand All @@ -32,7 +32,7 @@ export default function headerParser(el, { document, params, allMappings }) {
{
checkFn: (e) => e.querySelector('img'),
parseFn: (e, targetEl, x) => {
if (x < bodyWidth / 2) {
if (bodyWidth && x < bodyWidth / 2) {
targetEl.append(e);
return true;
}
Expand All @@ -42,7 +42,7 @@ export default function headerParser(el, { document, params, allMappings }) {
{
checkFn: (e) => e.querySelector(`a[href="/"], a[href="${originURL}"], a[href="${originURL}/"]`),
parseFn: (e, targetEl, x) => {
if (x < bodyWidth / 2) {
if (bodyWidth && x < bodyWidth / 2) {
targetEl.append(e);
return true;
}
Expand Down
Loading