Skip to content

UIKit Code Panel + View All / Clean Public Fixes! #1074

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

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions packages/core/src/lib/buildPatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => {
//
const graph = (patternlab.graph = loadPatternGraph(
patternlab,
deletePatternDir
patternlab.config.cleanPublic
));
const graphNeedsUpgrade = !PatternGraph.checkVersion(graph);
if (graphNeedsUpgrade) {
Expand All @@ -55,7 +55,7 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => {

// Flags
patternlab.incrementalBuildsEnabled = !(
deletePatternDir || graphNeedsUpgrade
patternlab.config.cleanPublic || graphNeedsUpgrade
);

//
Expand Down
2 changes: 1 addition & 1 deletion packages/edition-twig/patternlab-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}
},
"cacheBust": true,
"cleanPublic": true,
"cleanPublic": false,
"defaultPattern": "all",
"defaultShowPatternInfo": false,
"ishControlsHide": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

@media all and (min-width: $pl-bp-large) {
max-height: none;
height: 18rem;
flex-direction: row;
overflow: visible;
}
Expand Down Expand Up @@ -53,7 +52,6 @@
*/
.pl-c-pattern-info__panel {
padding: 1rem;
width: 100%;
flex-shrink: 0;
display: flex;
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ export const modalStyleguide = {
*/
onReady() {
// go through the panel toggles and add click event to the pattern extra toggle button
const els = document.querySelectorAll('.pl-js-pattern-extra-toggle');
for (let i = 0; i < els.length; ++i) {
els[i].onclick = function(e) {
const patternPartial = this.getAttribute('data-patternpartial');
const toggles = document.querySelectorAll('.pl-js-pattern-extra-toggle');

toggles.forEach(toggle => {
toggle.addEventListener('click', e => {
const patternPartial = toggle.getAttribute('data-patternpartial');
modalStyleguide.toggle(patternPartial);
};
}
});
});
},

/**
Expand Down Expand Up @@ -63,15 +64,17 @@ export const modalStyleguide = {
content = panelsUtil.addClickEvents(content, patternPartial);

// make sure the modal viewer and other options are off just in case
modalStyleguide.close(patternPartial);
// modalStyleguide.close(patternPartial);

// note it's turned on in the viewer
modalStyleguide.active[patternPartial] = true;

// make sure there's no content
div = document.getElementById('pl-pattern-extra-' + patternPartial);
if (div.childNodes.length > 0) {
div.removeChild(div.childNodes[0]);
if (div && div.childNodes) {
if (div.childNodes.length > 0) {
div.removeChild(div.childNodes[0]);
}
}

// add the content
Expand Down Expand Up @@ -108,9 +111,11 @@ export const modalStyleguide = {
toggle.classList.remove('pl-is-active');
}

document
.getElementById('pl-pattern-extra-' + patternPartial)
.classList.remove('pl-is-active');
if (document.getElementById('pl-pattern-extra-' + patternPartial)) {
document
.getElementById('pl-pattern-extra-' + patternPartial)
.classList.remove('pl-is-active');
}
},

/**
Expand Down
14 changes: 5 additions & 9 deletions packages/uikit-workshop/src/scripts/components/modal-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ export const modalViewer = {
*/
refresh(patternData, iframePassback, switchText) {
// if this is a styleguide view close the modal
if (iframePassback) {
modalViewer.close();
}

modalViewer.patternData = patternData;

Expand Down Expand Up @@ -348,9 +345,6 @@ export const modalViewer = {
data.iframePassback,
data.switchText
);

modalViewer.panelRendered = true;
modalViewer.previouslyRenderedPattern = data.patternData.patternPartial;
}
} else if (
data.event !== undefined &&
Expand Down Expand Up @@ -382,9 +376,11 @@ export const modalViewer = {
},

_stateChanged(state) {
modalViewer.active = state.app.drawerOpened;
if (modalViewer.iframeElement) {
modalViewer._handleInitialModalViewerState();
if (modalViewer.active !== state.app.drawerOpened) {
modalViewer.active = state.app.drawerOpened;
if (modalViewer.iframeElement) {
modalViewer._handleInitialModalViewerState();
}
}
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class IFrame extends BaseComponent {
// self.receiveIframeMessage = self.receiveIframeMessage.bind(self);
self.handleResize = self.handleResize.bind(self);
self.handleMouseDown = self.handleMouseDown.bind(self);
self.handleIframeLoaded = self.handleIframeLoaded.bind(self);
//set up the default for the
self.baseIframePath =
window.location.protocol +
Expand All @@ -53,9 +52,7 @@ class IFrame extends BaseComponent {

// update the currently active nav + add / update the page's query string
handlePageLoad(e) {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const patternParam = urlParams.get('p');
const patternParam = this.getPatternFromParam();

const currentPattern =
e.detail.pattern || window.config.defaultPattern || 'all';
Expand Down Expand Up @@ -104,9 +101,7 @@ class IFrame extends BaseComponent {

// navigate to the new PL page (based on the query string) when the page's pop state changes
handlePageChange(e) {
var queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
let patternParam = urlParams.get('p');
const patternParam = this.getPatternFromParam();

if (patternParam) {
this.navigateTo(patternParam);
Expand Down Expand Up @@ -327,25 +322,33 @@ class IFrame extends BaseComponent {
}

rendered() {
super.rendered && super.rendered();
this.iframe = this.querySelector('.pl-js-iframe');
this.iframeContainer = this.querySelector('.pl-js-vp-iframe-container');
this.iframeCover = this.querySelector('.pl-js-viewport-cover');

if (!this.hasUpdatedSrcset && this.iframe.src) {
this.hasUpdatedSrcset = true;
this.iframe.setAttribute('src', this.iframe.src);
this.iframe.removeAttribute('srcdoc');
}

super.rendered && super.rendered();
}

handleIframeLoaded() {
const self = this;
if (!this._hasInitiallyRendered) {
this._hasInitiallyRendered = true;
this.navigateTo(patternName, true);
getPatternFromParam() {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
let patternParam = urlParams.get('p');

if (patternParam && patternParam.includes('viewall')) {
patternParam = patternParam.replace(/-[0-9][0-9]/g, '');
}
return patternParam;
}

render() {
// use either the page's query string or the patternPartial data to auto-update the URL
var queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
let patternParam = urlParams.get('p');
let patternParam = this.getPatternFromParam();

if (!patternParam) {
if (window.patternData) {
Expand Down Expand Up @@ -412,6 +415,7 @@ class IFrame extends BaseComponent {
className={`pl-c-viewport__iframe pl-js-iframe pl-c-body--theme-${this.themeMode}`}
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals"
// srcdoc={render(<IframeInner />)}
srcdoc={render(<IframeInner />)}
src={url}
/>
{
Expand Down