Skip to content

Commit 0b45158

Browse files
feat: WC-274 component can opt for CMS styles (#1127)
* feat: WC-219 isolate external styles for component * fix: WC-219 change hook ext from jsx to js * fix: WC-219 fix hot reload error, add test The testing might be overkill. It passed before the fix was added. * refactor: WC-219 organize code more cleanly to help in debugging solution to hot reload error in dev * refactor: WC-219 change solution from DOM to CSS KNOWN ISSUES: Does not make CMS content look exactly correct. * chore: WC-219 remove cruft * feat: WC-219 hide navbar, simplify cms content CSS KNOWN ISSUE: CMS content still does not render perfect. * feat: WC-219 match test CMS content perfectly * chore: WC-219 delete shadow dom attempt * refactor: WC-219 rename files * fix: WC-219 missing part of "rename files" commit * chore: WC-219 delete outdated import * fix: WC-219 attrname vs attrName in JSX * fix: WC-219 file accidentally deleted * refactor: WC-219 extract breadcrumbs * fix: header styles overwritten by mimic-cms styles * fix: basic text color too dark cuz it is using portal basic text color instead of cms basic text color * feat!: footer from CMS TO DO: - Make footer conditional. - Fix footer position. BREAKING CHANGE: Footer always shown. Footer position is wrong. * refactor: cms-footer ID changed to just footer * chore: remove unused class * feat: only load CMS footer when necessary * docs: "make CMS styles conditional like … footer" * feat: "make CMS styles conditional like … footer" TODO: - reduce redundant code * docs: delete "make CMS styles conditional …" * fix: move DataFiles CSS back to DataFiles * refactor: simplify cms_styles.html * fix: cms_styles not disabled The style does not support disabled attribute. AI suggested media attribute. Unexpected, but sensible. * chore: restore new line * chore: simplify DataFiles…Breadcrumbs * refactor: CMSWrapper * refactor: clean up so DPM usage is clearer * chore: use `latest` cms image again v4.31.0 (latest) includes the new feature * fix: does not match CMS UI exactly Return CMS code to after <head>, which React/Vite appends with CSS that cms_styles must overwrite. * refactor cms_styles → cms_ui * chore: npm prettier--write client * chore: npm run lint:css * fix: footer on CMS layout * chore: remove duplicate code * chore: remove stray `async` keyword * fix: CMS footer present upon return to regular Portal * fix: DataFilesForDPM.global.css bleed * feat: CMSWrapper useDynamicStylesheets * refactor: move <main> to CMSWrapper only * chore: npm prettier --write client * docs: remove pagination comment * chore: comment format * test: other sample content * feat: navigate sample content * fix: remove tab-content/pane styles * fix: image url and attr whitepsace * fix: whtiespace between HTML tags for DPMRead * chore: npm prettier --write client * fix: misaligned image in <div> missing `container` Also added on design: - https://pprd.digitalrocks.tacc.utexas.edu/datasets/317/ - https://pprd.digitalrocks.tacc.utexas.edu/datasets/218/ * fix: wrong markup for heading Also fixed in design: - https://pprd.digitalrocks.tacc.utexas.edu/datasets/317/ - https://pprd.digitalrocks.tacc.utexas.edu/datasets/218/ * fix: nested container alignement mimics a CMS idiosyncrasy * chore: npm prettier --write client * fix: missing spaces * fix: misaligned nested container * fix: poetry lock * fix: do not import s-footer twice core-styles.cms.css provides it * fix: mirror TACC/Core-CMS-Custom#494 updates TACC/Core-CMS-Custom#494 And those updates made to templates on PPRD DigitalRocks. * deps: Core-Styles v2.45 * enhance: migrate styles from CDN to here * refactor: reorg styles so CMS can load 'em cleanly * chore: use latest corestyles, if used via CDN * chore: core-cms v4.33 via latest * fix: manually revert unintentional change probably related to task.digital-rocks being behind main * Revert "fix: manually revert unintentional change" This reverts commit 90890d2. * fix: condifently revert unintentional changes probably related to task.digital-rocks being behind main * fix: delete stray file probably related to task.digital-rocks being behind main * fix: inaccurate href value * fix: modals, dropdowns, tabs (new bootstrap, v5) Bootstrap v5 changes `data-` attributes for these features. Modals and Dropdowns require new naming. * fix: missing modals data- attr update Related to previous commit * chore: remove `data-tag-change-from` attributes These are cruft from CMS script that changes HTML elements which Django CMS did not allow me to put in a snippet. * fix: tooltips * fix: modal content styles * fix: limit portal modal content styles to portal * fix: dropdown styles * refactor: delete sample components + their styles --------- Co-authored-by: Shayan Khan <skhan@tacc.utexas.edu>
1 parent b49edd2 commit 0b45158

14 files changed

Lines changed: 195 additions & 31 deletions

File tree

client/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
},
7171
"devDependencies": {
7272
"@rollup/plugin-eslint": "^8.0.1",
73-
"@tacc/core-styles": "^2.39.4",
73+
"@tacc/core-styles": "^2.45.0",
7474
"@testing-library/jest-dom": "^5.0.2",
7575
"@testing-library/react": "^16.0.1",
7676
"@types/js-cookie": "^3.0.6",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react';
2+
3+
export default function CMSBreadcrumbs() {
4+
/* TODO: Move to …module.css OR into Core-Styles */
5+
/* https://github.com/TACC/Core-CMS/blob/v4.30.0/taccsite_cms/templates/nav_cms_breadcrumbs.html#L4-L11 */
6+
const breadcrumbCSS = `
7+
.s-breadcrumbs a:not([href]) {
8+
opacity: 1;
9+
color: unset;
10+
}
11+
`;
12+
13+
/* TODO: Migrate to JSX logic (when it exists) */
14+
React.useEffect(() => {
15+
// Disable href for the current page breadcrumb
16+
const crumbs = document.getElementById('cms-breadcrumbs');
17+
const secondLink = crumbs && crumbs.querySelector('li:nth-of-type(2) > a');
18+
if (secondLink) secondLink.removeAttribute('href');
19+
}, []);
20+
21+
/* TODO: Render based on data param, not as static content */
22+
return (
23+
<>
24+
<style dangerouslySetInnerHTML={{ __html: breadcrumbCSS }} />
25+
<nav className="s-breadcrumbs" id="cms-breadcrumbs">
26+
<ol itemScope itemType="https://schema.org/BreadcrumbList">
27+
<li
28+
itemScope
29+
itemProp="itemListElement"
30+
itemType="https://schema.org/ListItem"
31+
>
32+
<a href="/" itemProp="item">
33+
<span itemProp="name">Index</span>
34+
</a>
35+
<meta itemProp="position" content="1" />
36+
</li>
37+
<li
38+
itemScope
39+
itemProp="itemListElement"
40+
itemType="https://schema.org/ListItem"
41+
>
42+
<span itemProp="name">Browse Datasets</span>
43+
<meta itemProp="position" content="2" />
44+
</li>
45+
</ol>
46+
</nav>
47+
</>
48+
);
49+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './CMSBreadcrumbs';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, { useEffect } from 'react';
2+
3+
import PropTypes from 'prop-types';
4+
5+
function CMSWrapper({ children }) {
6+
useEffect(() => {
7+
// To (de)activate CMS styles on (un)mount
8+
window.dispatchEvent(new CustomEvent('cms-styles-activated'));
9+
return () => {
10+
window.dispatchEvent(new CustomEvent('cms-styles-deactivated'));
11+
};
12+
}, []);
13+
14+
return (
15+
<main id="mimic-cms" className="container">
16+
{children}
17+
</main>
18+
);
19+
}
20+
21+
CMSWrapper.propTypes = {
22+
children: PropTypes.node.isRequired,
23+
};
24+
25+
export default CMSWrapper;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './CMSWrapper';

client/src/components/_common/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export {
2525
default as IntroMessage,
2626
isKnownMessage as isKnownIntroMessage,
2727
} from './IntroMessage';
28+
export { default as CMSBreadcrumbs } from './CMSBreadcrumbs';
29+
export { default as CMSWrapper } from './CMSWrapper';
2830
export { default as CustomMessage } from './CustomMessage';
2931
export { default as Pill } from './Pill';
3032
export { default as TextCopyField } from './TextCopyField';

client/src/index.css

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@import url('./styles/global.css');
1+
@import url('./styles/global.css') layer(portal);
2+
3+
@layer portal {
24

35
/*
46
Sectioning Root
@@ -51,8 +53,7 @@ code {
5153
/* FAQ: The `html` and `body` boxes are only as tall as their content
5254
(which may be shorter than window height), cannot have siblings elements
5355
(would be influenced by force stretch), so force stretch outward. */
54-
html,
55-
body {
56+
body:not(.has-cms-ui) {
5657
/* As a stretched item */
5758
position: absolute;
5859
left: 0;
@@ -75,31 +76,34 @@ body {
7576
/* FAQ: The `.content` and `#react-root` boxes are only as tall as their content
7677
(which may be shorter than window height), can have siblings elements
7778
(would be influenced by force stretch), so gently stretch outward. */
78-
body {
79+
body:not(.has-cms-ui) {
7980
/* As a flex container */
8081
display: flex;
8182
flex-direction: column;
8283
}
83-
body > .content {
84+
body:not(.has-cms-ui) .content {
8485
/* As a flex item */
8586
flex-grow: 1;
8687

8788
/* As a flex container */
8889
display: flex;
8990
flex-direction: column;
9091
}
91-
#react-root {
92+
body:not(.has-cms-ui) #react-root {
9293
/* As a flex item */
9394
flex-grow: 1;
9495

9596
/* As a stretched item container */
9697
position: relative;
9798
}
98-
#react-root > :only-child {
99+
body:not(.has-cms-ui) #react-root > :only-child {
99100
/* As a stretched item */
100101
position: absolute;
101102
left: 0;
102103
right: 0;
103104
top: 0;
104105
bottom: 0;
105106
}
107+
108+
/* end @layer portal */
109+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
i[data-bs-toggle="tooltip"] {
2+
font-style: normal;
3+
}
4+
5+
.tooltip-inner {
6+
font-size: var(--global-font-size--medium);
7+
}

client/src/styles/global.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
/* SETTINGS */
55
@import url('@tacc/core-styles/src/lib/_imports/settings/border.css');
66
@import url('./settings/color.css');
7-
@import url('./settings/font.css');
7+
@import url('@tacc/core-styles/dist/settings/font.css');
8+
@import url('@tacc/core-styles/dist/settings/font--portal.css');
89
@import url('./settings/space.css');
910

1011
/* TOOLS */
@@ -29,6 +30,7 @@
2930
@import url('./components/bootstrap.nav.css');
3031
@import url('./components/bootstrap.utils.css');
3132
@import url('./components/bootstrap.button.css');
33+
@import url('./components/bootstrap.tooltip.css');
3234
@import url('./components/mui.tabs.css');
3335

3436
/* TRUMPS */

0 commit comments

Comments
 (0)