Skip to content

Commit

Permalink
Merge pull request #1212 from codaxy/theme-packed-dark
Browse files Browse the repository at this point in the history
Theme packed dark (first version)
  • Loading branch information
mstijak authored May 8, 2024
2 parents f868fec + 94554e2 commit 1fcd2ac
Show file tree
Hide file tree
Showing 42 changed files with 2,509 additions and 1,525 deletions.
6 changes: 6 additions & 0 deletions docs/content/widgets/configs/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ export default {
Set to `true` to disable moving the window by dragging the header.
</Md></cx>
},
pad: {
type: 'boolean',
description: <cx><Md>
Set to `true` to add default padding to the window body.
</Md></cx>
},
};
3 changes: 3 additions & 0 deletions gallery/components/ThemeLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function importTheme(theme) {

case "space-blue":
return import(/* webpackChunkName: 'space-blue' */ "../themes/space-blue");

case "packed-dark":
return import(/* webpackChunkName: 'packed-dark' */ "../themes/packed-dark");
}
}

Expand Down
1 change: 1 addition & 0 deletions gallery/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = (production) => ({
"cx-theme-aquamarine": p("../packages/cx-theme-aquamarine"),
"cx-theme-material-dark": p("../packages/cx-theme-material-dark"),
"cx-theme-space-blue": p("../packages/cx-theme-space-blue"),
"cx-theme-packed-dark": p("../packages/cx-theme-packed-dark"),
//uncomment the line below to alias cx-react to cx-preact or some other React replacement library
//'cx-react': 'cx-preact',
},
Expand Down
4 changes: 2 additions & 2 deletions gallery/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>CxJS Gallery</title>
<link
href="https://fonts.googleapis.com/css?family=Roboto:400,500|Open+Sans:400,500,600,700|Material+Icons"
href="https://fonts.googleapis.com/css?family=Roboto:400,500|Open+Sans:400,500,600,700|Material+Icons|Inter"
rel="stylesheet"
/>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,Array.from,Array.prototype.find,Array.prototype.findIndex,Math.log10,Intl.~locale.en"></script>
Expand Down
8 changes: 5 additions & 3 deletions gallery/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
background: var(--master-sidebar-background);
color: var(--master-sidebar-color);

.cxb-link.cxs-active, .cxb-link:hover {
.cxb-link.cxs-active,
.cxb-link:hover {
color: var(--master-sidebar-active-color);
}
}



p:last-child {
margin-bottom: 0;
}
1 change: 1 addition & 0 deletions gallery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"cx-theme-frost": "^18.7.1",
"cx-theme-material": "^18.7.0",
"cx-theme-material-dark": "^20.1.0",
"cx-theme-packed-dark": "^24.4.1",
"cx-theme-space-blue": "^20.1.0",
"intl": "^1.2.5",
"plural": "^1.1.0",
Expand Down
217 changes: 115 additions & 102 deletions gallery/routes/general/window/states.tsx
Original file line number Diff line number Diff line change
@@ -1,130 +1,143 @@
import {cx, Section, FlexRow, Window, MsgBox, Button, TextField, DateField, TextArea} from 'cx/widgets';
import {LabelsLeftLayout, bind, expr} from 'cx/ui';
import { cx, Section, FlexRow, Window, MsgBox, Button, TextField, DateField, TextArea } from "cx/widgets";
import { LabelsLeftLayout, bind, expr } from "cx/ui";

const showModal = (store) => {
let modal = Window.create({
title: 'Modal',
modal: true,
center: true,
style: 'width: 500px; max-width: 90vw',
bodyStyle: "padding: 20px",
items: <cx>
let modal = Window.create({
title: "Modal",
modal: true,
center: true,
pad: true,
style: "width: 500px; max-width: 90vw",
items: (
<cx>
<p>
Modal windows have a modal backdrop which prevents
user from interacting with the contents on the page
while the window is open.
Modal windows have a modal backdrop which prevents user from interacting with the contents on the page
while the window is open.
</p>
<p>
There can be multiple modal windows open in the same time.
</p>
<Button mod="hollow"
onClick={(e, {store}) => {
showModal(store);
}}
<p>There can be multiple modal windows open in the same time.</p>
<Button
onClick={(e, { store }) => {
showModal(store);
}}
>
Open Modal
Open Modal
</Button>
</cx>
});
</cx>
),
});

modal.open(store);
modal.open(store);
};

export default <cx>
<a href="https://github.com/codaxy/cx/tree/master/gallery/routes/general/window/states.tsx" target="_blank" putInto="github">Source Code</a>
<FlexRow wrap spacing="large" target="tablet" align="start">

<Window title="Contact"
visible={{bind: "contact.visible", defaultValue: false}}
export default (
<cx>
<a
href="https://github.com/codaxy/cx/tree/master/gallery/routes/general/window/states.tsx"
target="_blank"
putInto="github"
>
Source Code
</a>
<FlexRow wrap spacing="large" target="tablet" align="start">
<Window
title="Contact"
visible={{ bind: "contact.visible", defaultValue: false }}
center
styles="width:500px;max-width: 90vw"
modal>
<div style={{padding: "20px"}} layout={{type: LabelsLeftLayout, mod: 'stretch'}}>
<TextField label="Name" value={bind("$page.contact.name")} style={{width: '100%'}}/>
<TextField label="Email" value={bind("$page.contact.email")} style={{width: '100%'}}/>
<TextArea label="Message" value={bind("$page.contact.message")} rows={5} style={{width: '100%'}}/>
<DateField label="Date" value={bind("$page.contact.date")}/>
pad
>
<div layout={{ type: LabelsLeftLayout, mod: "stretch" }}>
<TextField label="Name" value={bind("$page.contact.name")} style={{ width: "100%" }} />
<TextField label="Email" value={bind("$page.contact.email")} style={{ width: "100%" }} />
<TextArea label="Message" value={bind("$page.contact.message")} rows={5} style={{ width: "100%" }} />
<DateField label="Date" value={bind("$page.contact.date")} />
</div>
<FlexRow putInto="footer" spacing justify="end">
<Button mod="primary">Submit</Button>
<Button onClick={(e, ins) => {
ins.parentOptions.dismiss()
}}>
Cancel
</Button>
<Button mod="primary">Submit</Button>
<Button
onClick={(e, ins) => {
ins.parentOptions.dismiss();
}}
>
Cancel
</Button>
</FlexRow>
</Window>
</Window>

<Window
<Window
title="Backdrop"
backdrop
center
styles="width:500px;max-width: 90vw"
visible={{bind: "backdrop.visible"}}
bodyStyle="padding: 50px"
>
<p>
Windows with backdrop can be closed by clicking anywhere outside the window.
</p>
</Window>
visible={{ bind: "backdrop.visible" }}
pad
>
<p>Windows with backdrop can be closed by clicking anywhere outside the window.</p>
</Window>

<Section mod="well" hLevel={4} title="Options">
<Section mod="well" hLevel={4} title="Options">
<FlexRow wrap spacing>
<Button
onClick={(e, {store}) => {
store.toggle("contact.visible")
}}
>
Standard
</Button>
<Button
onClick={(e, { store }) => {
store.toggle("contact.visible");
}}
>
Standard
</Button>

<Button
onClick={(e, {store}) => {
store.toggle("backdrop.visible")
}}
>
Backdrop
</Button>
<Button
onClick={(e, { store }) => {
store.toggle("backdrop.visible");
}}
>
Backdrop
</Button>

<Button
onClick={(e, {store}) => {
showModal(store);
}}
>
Modal
</Button>
<Button
onClick={(e, { store }) => {
showModal(store);
}}
>
Modal
</Button>
</FlexRow>
</Section>
<Section mod="well" hLevel={4} title="MsgBox">
</Section>
<Section mod="well" hLevel={4} title="MsgBox">
<FlexRow wrap spacing>
<Button
onClick={(e) => {
MsgBox.alert("This is an important message!");
}}
>
Alert
</Button>

<Button onClick={(e) => {
MsgBox.alert("This is an important message!")
}}>
Alert
</Button>


<Button onClick={(e) => {
MsgBox.yesNo("Do you like CxJS?")
.then(result => {
if (result == 'yes') {
MsgBox.alert({
message: <div ws>
Great! Please support CxJS by giving it
{' '}
<a href="https://github.com/codaxy/cxjs" target="_blank">a star on GitHub!</a>.
</div>
});
}
})
}}>
Yes or No
</Button>
<Button
onClick={(e) => {
MsgBox.yesNo("Do you like CxJS?").then((result) => {
if (result == "yes") {
MsgBox.alert({
message: (
<div ws>
Great! Please support CxJS by giving it{" "}
<a href="https://github.com/codaxy/cxjs" target="_blank">
a star on GitHub!
</a>
.
</div>
),
});
}
});
}}
>
Yes or No
</Button>
</FlexRow>
</Section>
</FlexRow>
</cx>
</Section>
</FlexRow>
</cx>
);

import {hmr} from '../../hmr.js';
hmr(module);
import { hmr } from "../../hmr.js";
hmr(module);
9 changes: 7 additions & 2 deletions gallery/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ let themes = {
"~/dark": "Dark",
};

if (process.env.NODE_ENV == "development") {
// not ready for prime time
themes["~/packed-dark"] = "Packed Dark";
}

export default (
<cx>
<MasterLayout
Expand Down Expand Up @@ -49,7 +54,7 @@ export default (
redirect={computable(
"$themeRoute.remainder",
"$route.theme",
(remainder, theme) => `~/${theme || "aquamarine"}${remainder || "/button/states"}`
(remainder, theme) => `~/${theme || "aquamarine"}${remainder || "/button/states"}`,
)}
/>
</Route>
Expand All @@ -75,7 +80,7 @@ export default (
<ThemeLoader theme={bind("$themeRoute.theme")}>
<main class="main" layout={FirstVisibleChildLayout}>
{list.map((cat) =>
cat.items?.map((item) => <SandboxedAsyncRoute route={item.route} content={item.content} />)
cat.items?.map((item) => <SandboxedAsyncRoute route={item.route} content={item.content} />),
)}
<Section title="Page Not Found" mod="card">
This page doesn't exists. Please check your URL.
Expand Down
5 changes: 5 additions & 0 deletions gallery/themes/packed-dark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import style from "./packed-dark.useable.scss";
import { registerTheme } from "./index";
import { applyThemeOverrides } from "cx-theme-packed-dark/src";

registerTheme("packed-dark", style, applyThemeOverrides);
15 changes: 15 additions & 0 deletions gallery/themes/packed-dark.useable.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$cx-include-global-rules: true;

@import "~cx-theme-packed-dark/src/variables";
@import "./util/divide.scss";
@import "~cx-theme-packed-dark/src/index";

@import "./util/customize-master";

@include customize-master(
$brand-background: #2281b1,
$brand-highlight-color: #2281b1,
$sidebar-background-color: rgba(0, 0, 0, 0.2),
$sidebar-link-color: rgba(255, 255, 255, 0.6),
$sidebar-active-link-color: rgba(255, 255, 255, 0.8)
);
Loading

0 comments on commit 1fcd2ac

Please sign in to comment.