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

Responsive Layout and Theme Mixins #176

Merged
merged 39 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4a47e42
Clutter Cleanup
tomerlichtash Apr 24, 2022
afb6bab
Clutter Cleanup
tomerlichtash Apr 24, 2022
0de7b9d
Move page-width to Page component
tomerlichtash Apr 24, 2022
7794f03
Clutter Cleanup
tomerlichtash Apr 25, 2022
b7827e4
Theme Mixins
tomerlichtash Apr 25, 2022
2e6d431
Theme Mixins and Style Cleanup
tomerlichtash Apr 26, 2022
d9dbb83
Menu Mixin
tomerlichtash Apr 26, 2022
9beaaf9
Theme Selector base style
tomerlichtash Apr 27, 2022
d9a8d95
Full themabity
tomerlichtash Apr 27, 2022
ed6dfc1
Footer translations
tomerlichtash Apr 27, 2022
db8a805
Themable Footer, LocaleSelector, ThemeSelector
tomerlichtash Apr 27, 2022
ff9a066
Note Mixin
tomerlichtash Apr 27, 2022
530ffc3
Scrollbar mixin fix
tomerlichtash Apr 27, 2022
6e6bb20
Themed CopyURL Tooltip Content and general cleanup
tomerlichtash Apr 28, 2022
b835d5f
Dismiss common.st.css
tomerlichtash Apr 28, 2022
c97c23b
Themes folder and Nav components cleanup
tomerlichtash Apr 28, 2022
8bf9e23
Trim theme props
tomerlichtash Apr 28, 2022
aca8adb
Theme enhancements
tomerlichtash Apr 29, 2022
7c99586
Margins and Paddings
tomerlichtash Apr 29, 2022
2ad5ab5
Light Theme optimization
tomerlichtash Apr 29, 2022
4ca26e9
remove unused st
tomerlichtash Apr 29, 2022
312528b
Add glossary term source url
tomerlichtash Apr 29, 2022
d8e3dd8
Style extends for Dynamic Content Components
tomerlichtash Apr 29, 2022
005a53a
Merged with master
tomerlichtash Apr 29, 2022
df0e201
Align ThemeSelector icon
tomerlichtash Apr 29, 2022
9739e8e
SiteTitleLinkTextColor
tomerlichtash Apr 29, 2022
79eb4a1
Dark theme reset
tomerlichtash Apr 30, 2022
9b05f4a
Footer design
tomerlichtash Apr 30, 2022
b306e56
Align header items
tomerlichtash Apr 30, 2022
756e0ef
Figure image center in actual scale
tomerlichtash Apr 30, 2022
1c3285a
Header layout
tomerlichtash Apr 30, 2022
c7ae5f7
Replace locale style states with textDirection
tomerlichtash Apr 30, 2022
70a50bb
Merge branch 'master' into responsive-layout
tomerlichtash Apr 30, 2022
7c73638
useEffect in CopyUrlButton
tomerlichtash May 1, 2022
f53693f
Remove isHome behaviour
tomerlichtash May 1, 2022
0a580bb
Fix typo
tomerlichtash May 1, 2022
45f0b84
Fix rendering issues for Menu
tomerlichtash May 2, 2022
d906d3d
Add uniqueId for PopoverToolbar items
tomerlichtash May 2, 2022
ef9fadc
Remove redudndant titles from LocaleSelector
tomerlichtash May 2, 2022
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
2 changes: 1 addition & 1 deletion public/content/glossary/real-programmer/index.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
glossary_key: "REAL_PROGRAMMER"
# source_url: TBD
source_url: http://www.catb.org/jargon/html/R/Real-Programmer.html
source_name: The Jargon File
---

Expand Down
27 changes: 27 additions & 0 deletions snippets/debug-content-component-style.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
---------------------------------
DEBUG
---------------------------------
*/
/* Debug Media Queries */
/* @st-import Responsive from "./responsive-mixin.st.css"; */
/* .root {
-st-mixin: Responsive;
} */

/*
Debug Line Index
*/
/* @st-scope .root {
ContentComponent:type(paragraph):hover::before {
color: red;
}
ContentComponent:type(paragraph)::before {
content: attr(data-line-index);
color: #c0c0c0;
width: 20px;
padding-right: 20px;
text-align: right;
display: inline-block;
}
} */
7 changes: 7 additions & 0 deletions src/components/bibliography/bibliography-mixin.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@namespace "BibliographyMixin";

@st-import Bibliography from "./bibliography.st.css";

.root {
-st-extends: Bibliography;
}
5 changes: 2 additions & 3 deletions src/components/content/content-blocks/figure/figure.st.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

.root {
-st-mixin: boxSizing;
text-align: center;
margin: 0;
}

.img {
width: 100%;
}
.img {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ import { ContentIterator } from "../../content-iterator";
import { Link } from "../link/link";
import AnnotationLink from "../annotation-link";
import Popover from "../../../popover";
import { ReactThemeContext } from "../../../../contexts/theme-context";
import { ReactLocaleContext } from "../../../../contexts/locale-context";
import { ReactQueryContext } from "../../../../contexts/query-context";
import DynamicContentBrowser from "../../../dynamic-content-browser";
import { ReactDynamicContentContext } from "../../../../contexts/dynamic-content-context";
import {
st as layoutStyle,
classes as layoutClasses,
} from "../../../layout/layout.st.css";

const getTriggerComp = (
type: DynamicContentTypes,
Expand All @@ -40,8 +35,7 @@ export const LinkSelector = ({
const { displayType, key } = node;
const dcContext = useContext(ReactDynamicContentContext);
const queryContext = useContext(ReactQueryContext);
const { locale, textDirection } = useContext(ReactLocaleContext);
const { themeRef } = useContext(ReactThemeContext);
const { textDirection } = useContext(ReactLocaleContext);
const { query } = queryContext;
const { getQueryUrl, registerNode, onExit } = query;
const nodeWithQuery = registerNode(node);
Expand Down Expand Up @@ -79,8 +73,6 @@ export const LinkSelector = ({
side={textDirection === "ltr" ? "right" : "left"}
trigger={getTriggerComp(linkType, componentData, className)}
portalled={true}
portalStyles={layoutStyle(layoutClasses.root, { locale })}
contentClassName={themeRef}
>
<DynamicContentBrowser node={node} />
</Popover>
Expand Down
14 changes: 11 additions & 3 deletions src/components/content/content-blocks/paragraph/paragraph.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { ContentComponentProps } from "../../../../interfaces/models";
import { ContentComponent } from "../../index";
import { classes } from "./paragraph.st.css";
import { st, classes } from "./paragraph.st.css";

export const Paragraph = ({
componentData,
Expand All @@ -19,15 +19,23 @@ export const Paragraph = ({

if (children.length === 1 && children[0].type === "text") {
return (
<p key={node.key} className={className} data-line-index={line + 1}>
<p
key={node.key}
className={st(classes.root, className)}
data-line-index={line + 1}
>
{anchor}
{node.children[0].text}
</p>
);
}

return (
<p key={node.key} className={className} data-line-index={line + 1}>
<p
key={node.key}
className={st(classes.root, className)}
data-line-index={line + 1}
>
{anchor}
{children.map((node) => (
<ContentComponent
Expand Down
3 changes: 3 additions & 0 deletions src/components/content/content-blocks/section/section.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@namespace "Section";

.root {}
3 changes: 2 additions & 1 deletion src/components/content/content-blocks/section/section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
IMLParsedNode,
ContentComponentProps,
} from "../../../../interfaces/models";
import { st, classes } from "./section.st.css";

export const Section = ({
componentData,
Expand All @@ -14,7 +15,7 @@ export const Section = ({
? node.children
: [];
return (
<div className={className} key={node.key}>
<div className={st(classes.root, className)} key={node.key}>
{elements.map((node) => {
return (
<ContentComponent
Expand Down
37 changes: 37 additions & 0 deletions src/components/content/content-component-mixin.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@namespace "ContentComponentMixin";

@st-import ContentComponent from "./content-component.st.css";

:vars {
LinkColor: blue;
LinkColorHover: red;
ErrorBgColor: red;
ErrorTextColor: white;
MarginBottom: 1.8rem;
}

.root {
-st-extends: ContentComponent;
}

.root:type(section) {
margin-bottom: value(MarginBottom);
}

.root:type(blockquote) {
/* line-height: value(MarginBottom); */
padding: 0 value(MarginBottom);
margin: value(MarginBottom);
}

.root:type(link) {
color: value(LinkColor);
}
.root:type(link):hover {
color: value(LinkColorHover);
}

.root::error {
background: value(ErrorBgColor);
color: value(ErrorTextColor);
}
19 changes: 1 addition & 18 deletions src/components/content/content-component.st.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,4 @@
));
}

.root:type(section),
.root:type(blockquote) {
margin-bottom: 1.8rem;
}

.root:type(paragraph),
.root:type(blockquote) {
line-height: 1.8rem;
}

.root:type(blockquote) {
padding: 0 1.8rem;
}

.error {
background: red;
color: #fff;
}
.error {}
3 changes: 2 additions & 1 deletion src/components/content/content-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import { st, classes } from "./content-component.st.css";

export const ContentComponent = ({
componentData,
className,
}: ContentComponentProps): JSX.Element => {
const { node } = componentData;
const { key, type } = node;
const stylableClassName = st(classes.root, { type });
const stylableClassName = st(classes.root, { type }, className);

if (!key) {
console.warn("missing key on", node);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@namespace "DynamicContentViewerMixin";

@st-import DynamicContentViewer from "./dynamic-content-viewer.st.css";

:vars {
ParagraphTextSize: 1rem;
ParagraphLineHeight: 1.8rem;
}

.root {
-st-extends: DynamicContentViewer;
}

.root::contentComponent:type(paragraph){
line-height: value(ParagraphLineHeight);
font-size: value(ParagraphTextSize);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@namespace "DynamicContentViewer";

@st-import Note from "../../note/note.st.css";
@st-import ContentComponent from "../content-component.st.css";

.root {}

.note {
-st-extends: Note;
}

.contentComponent {
-st-extends: ContentComponent;
}

.error {}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { contentUtils } from "../../../lib/content-utils";
import Note from "../../note";
import { ReactDynamicContentContext } from "../../../contexts/dynamic-content-context";
import { mlUtils } from "../../../lib/ml-utils";
import { st, classes } from "./dynamic-content-viewer.st.css";

export interface DynamicContentViewerProps extends ComponentProps {
url: string;
Expand All @@ -16,6 +17,7 @@ export interface DynamicContentViewerProps extends ComponentProps {

export const DynamicContentViewer = ({
url,
className,
}: DynamicContentViewerProps): JSX.Element => {
const [item, setItem] = useState<IParsedPageData>(null);
const pageContext = useContext(ReactPageContext);
Expand Down Expand Up @@ -59,7 +61,7 @@ export const DynamicContentViewer = ({
}, [url, dynamicContentContext, pageContext, locale]);

if (error) {
return <div>{error}</div>;
return <div className={classes.error}>{error}</div>;
}

if (elements) {
Expand All @@ -73,23 +75,30 @@ export const DynamicContentViewer = ({
const itemType =
itemData.type === DynamicContentTypes.Glossary ? "ref" : "note";
const contents = elements.map((node) => (
<ContentComponent key={mlUtils.uniqueId()} componentData={{ node }} />
<ContentComponent
key={mlUtils.uniqueId()}
componentData={{ node }}
className={classes.contentComponent}
/>
));

return (
<Note
type={itemType}
contents={contents}
label={label}
title={translate(glossary_key)}
term={locale === "en" ? "" : translate(glossary_key, "en")}
sources={[
{
name: source_name,
url: source_url,
},
]}
/>
<div className={st(classes.root, className)}>
<Note
className={classes.root}
type={itemType}
contents={contents}
label={label}
title={translate(glossary_key)}
term={locale === "en" ? "" : translate(glossary_key, "en")}
sources={[
{
name: source_name,
url: source_url,
},
]}
/>
</div>
);
}

Expand Down
28 changes: 28 additions & 0 deletions src/components/copy-button/copy-url-button-content-mixin.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@namespace "CopyUrlButtonContentMixin";

@st-import CopyButtonContent from "./copy-url-button-content.st.css";
@st-import [TooltipArrow] from "../../theme/mixins.st.css";

:vars {
ContentBgColor: #808080;
ContentPadding: 0.25rem 0.5rem;
TooltipRadius: 6px;
TextColor: #fff;
TextSize: 0.85rem;
TooltipArrowColor: black;
}

.root {
-st-extends: CopyButtonContent;
background-color: value(ContentBgColor);
padding: value(ContentPadding);
border-radius: value(TooltipRadius);
color: value(TextColor);
font-size: value(TextSize);
}

.root::tooltipArrow {
-st-mixin: TooltipArrow(
TooltipArrowColor value(TooltipArrowColor)
);
}
5 changes: 5 additions & 0 deletions src/components/copy-button/copy-url-button-content.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@namespace "CopyUrlButtonContent";

.root {}

.tooltipArrow {}
16 changes: 16 additions & 0 deletions src/components/copy-button/copy-url-button-trigger-mixin.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@namespace "CopyUrlButtonTriggerMixin";

@st-import CopyUrlButtonTrigger from "./copy-url-button-trigger.st.css";
@st-import [IconFill] from "../../theme/mixins.st.css";

:vars {
IconFillColor: black;
}

.root {
-st-extends: CopyUrlButtonTrigger;
}

.root:checked {
-st-mixin: IconFill(FillColor value(IconFillColor));
}
9 changes: 9 additions & 0 deletions src/components/copy-button/copy-url-button-trigger.st.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@namespace "CopyUrlButton";

.root {
-st-states: checked(boolean);
}

.root:checked {
cursor: default;
}
Loading