Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed 7af6574 with MkDocs version: 1.5.3
Browse files Browse the repository at this point in the history
Unknown committed Jan 7, 2024
0 parents commit 5c9c294
Showing 81 changed files with 46,633 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
1,086 changes: 1,086 additions & 0 deletions 404.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
www.counterweight.dev
77 changes: 77 additions & 0 deletions _assets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
:root {
--class-color: #00b8d4;
--class-header-color: #00b8d41a;
--function-color: #448aff;
--function-header-color: #448aff1a;
}

article > .doc {
border-style: solid;
border-width: 0.05rem;
border-radius: 0.2rem;
padding: 0.6rem 0.6rem;
box-shadow: var(--md-shadow-z1);
}

article > .doc + .doc {
margin-top: 1rem;
}

.doc-object-name {
font-family: monospace;
}

h3.doc {
margin: -0.6rem;
padding: 0.6rem;
}

article > .doc.doc-class {
border-color: var(--class-color);
}

.doc-class > h3.doc {
background-color: var(--class-header-color);
}

article > .doc.doc-function {
border-color: var(--function-color);
}

.doc-function > h3.doc {
background-color: var(--function-header-color);
}

/* Indentation. */
div.doc-contents:not(.first) {
padding-left: 25px;
border-left: .05rem solid var(--md-typeset-table-color);
}

/* Mark external links as such. */
a.autorefs-external::after {
/* https://primer.style/octicons/arrow-up-right-24 */
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="rgb(0, 0, 0)" d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
content: ' ';

display: inline-block;
position: relative;
top: 0.1em;
margin-left: 0.2em;
margin-right: 0.1em;

height: 1em;
width: 1em;
border-radius: 100%;
background-color: var(--md-typeset-a-color);
}
a.autorefs-external:hover::after {
background-color: var(--md-accent-fg-color);
}

/* Styles for SVG screenshots */

.md-typeset img {
width: 100%;
height: 100%;
}
825 changes: 825 additions & 0 deletions _examples/absolute-positioning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions _examples/absolute_positioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# --8<-- [start:example]
from counterweight.app import app
from counterweight.components import component
from counterweight.controls import Quit, Screenshot
from counterweight.elements import Div, Text
from counterweight.styles.utilities import *

extra_style = border_light | pad_1 | margin_1


@component
def root() -> Div:
return Div(
style=col | justify_children_space_around,
children=[
Div(
style=border_heavy,
children=[
Text(
style=text_green_600,
content="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
)
]
+ [
Text(
style=absolute(x=x, y=y) | extra_style | margin_red_600,
content=f"absolute(x={x}, y={y})",
)
for x, y in (
(0, 0),
(10, -7),
(33, 3),
)
],
),
Div(
style=border_heavy,
children=[
Text(
style=text_cyan_600,
content="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
)
]
+ [
Text(
style=absolute(x=x, y=y) | extra_style | margin_amber_600,
content=f"absolute(x={x}, y={y})",
)
for x, y in (
(0, 0),
(10, -7),
(33, 3),
)
],
),
],
)


# --8<-- [end:example]

if __name__ == "__main__":
import asyncio
from pathlib import Path

THIS_DIR = Path(__file__).parent

asyncio.run(
app(
root,
headless=True,
dimensions=(60, 30),
autopilot=[
Screenshot.to_file(THIS_DIR / "absolute-positioning.svg", indent=1),
Quit(),
],
)
)
386 changes: 386 additions & 0 deletions _examples/border-healing-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
386 changes: 386 additions & 0 deletions _examples/border-healing-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions _examples/border_healing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# --8<-- [start:example]
from counterweight.app import app
from counterweight.components import component
from counterweight.controls import AnyControl, Quit, Screenshot, ToggleBorderHealing
from counterweight.elements import Div, Text
from counterweight.events import KeyPressed
from counterweight.keys import Key
from counterweight.styles.utilities import *

common_style = align_self_stretch | justify_children_center | align_children_center
border_kind = border_double


@component
def root() -> Div:
def on_key(event: KeyPressed) -> AnyControl | None:
match event.key:
case Key.Space:
return ToggleBorderHealing()
case _:
return None

return Div(
style=row | common_style,
on_key=on_key,
children=[
Div(
style=col | common_style,
children=[
box("A1", edge_style=None),
box("A2", edge_style=border_bottom_left_right),
],
),
Div(
style=col | common_style,
children=[
Div(
style=row | common_style,
children=[
box("B1", edge_style=border_top_bottom_right),
box("B2", edge_style=border_top_bottom_right),
],
),
Div(
style=row | common_style,
children=[
box("C1"),
box("C2"),
box("C3"),
box("C4"),
],
),
Div(
style=row | common_style,
children=[
box("D1"),
box("D2"),
box("D3"),
],
),
],
),
],
)


@component
def box(s: str, edge_style: Style | None = border_bottom_right) -> Div:
return Div(
style=common_style | border_kind | edge_style,
children=[
Text(
style=text_justify_center | (text_cyan_500 if edge_style == border_bottom_right else text_amber_500),
content=s,
)
],
)


# --8<-- [end:example]

if __name__ == "__main__":
import asyncio
from pathlib import Path

THIS_DIR = Path(__file__).parent

asyncio.run(
app(
root,
headless=True,
dimensions=(60, 20),
autopilot=[
Screenshot.to_file(THIS_DIR / "border-healing-on.svg", indent=1),
KeyPressed(key=Key.Space),
Screenshot.to_file(THIS_DIR / "border-healing-off.svg", indent=1),
Quit(),
],
)
)
480 changes: 480 additions & 0 deletions _examples/fixed-positioning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions _examples/fixed_positioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# --8<-- [start:example]
from counterweight.app import app
from counterweight.components import component
from counterweight.controls import Quit, Screenshot
from counterweight.elements import Div, Text
from counterweight.styles.utilities import *

extra_style = border_heavy | pad_1 | margin_1 | margin_red_600


@component
def root() -> Div:
return Div(
style=row,
children=[
Text(
style=fixed(x=x, y=y) | extra_style,
content=f"fixed(x={x}, y={y})",
)
for x, y in (
(0, 0),
(10, 10),
(30, 20),
(15, 25),
(33, 3),
)
],
)


# --8<-- [end:example]

if __name__ == "__main__":
import asyncio
from pathlib import Path

THIS_DIR = Path(__file__).parent

asyncio.run(
app(
root,
headless=True,
dimensions=(60, 30),
autopilot=[
Screenshot.to_file(THIS_DIR / "fixed-positioning.svg", indent=1),
Quit(),
],
)
)
7 changes: 7 additions & 0 deletions _examples/generate-screenshots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euxo pipefail

THIS_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

echo ${THIS_DIR}/*.py | xargs -n 1 -P 8 python
835 changes: 835 additions & 0 deletions _examples/relative-positioning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions _examples/relative_positioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# --8<-- [start:example]
from counterweight.app import app
from counterweight.components import component
from counterweight.controls import Quit, Screenshot
from counterweight.elements import Div, Text
from counterweight.styles.utilities import *

extra_style = pad_1 | margin_1


@component
def root() -> Div:
return Div(
style=col | justify_children_space_between,
children=[
Div(
style=row,
children=[
Text(
style=relative(x=x, y=y) | extra_style | border_lightrounded | margin_red_600,
content=f"relative(x={x}, y={y})",
)
for x, y in (
(0, 0),
(0, 5),
(0, -3),
)
],
),
Div(
style=row,
children=[
Text(
style=relative(x=x, y=y) | extra_style | border_heavy | margin_amber_600,
content=f"relative(x={x}, y={y})",
)
for x, y in (
(0, 0),
(3, 3),
(0, 0),
)
],
),
Div(
style=row,
children=[
Text(
style=relative(x=x, y=y) | extra_style | border_light | margin_violet_700,
content=f"relative(x={x}, y={y})",
)
for x, y in (
(0, 0),
(5, 0),
(0, -5),
)
],
),
],
)


# --8<-- [end:example]

if __name__ == "__main__":
import asyncio
from pathlib import Path

THIS_DIR = Path(__file__).parent

asyncio.run(
app(
root,
headless=True,
dimensions=(80, 30),
autopilot=[
Screenshot.to_file(THIS_DIR / "relative-positioning.svg", indent=1),
Quit(),
],
)
)
64 changes: 64 additions & 0 deletions assets/_mkdocstrings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

/* Avoid breaking parameter names, etc. in table cells. */
.doc-contents td code {
word-break: normal !important;
}

/* No line break before first paragraph of descriptions. */
.doc-md-description,
.doc-md-description>p:first-child {
display: inline;
}

/* Max width for docstring sections tables. */
.doc .md-typeset__table,
.doc .md-typeset__table table {
display: table !important;
width: 100%;
}

.doc .md-typeset__table tr {
display: table-row;
}

/* Defaults in Spacy table style. */
.doc-param-default {
float: right;
}

/* Keep headings consistent. */
h1.doc-heading,
h2.doc-heading,
h3.doc-heading,
h4.doc-heading,
h5.doc-heading,
h6.doc-heading {
font-weight: 400;
line-height: 1.5;
color: inherit;
text-transform: none;
}

h1.doc-heading {
font-size: 1.6rem;
}

h2.doc-heading {
font-size: 1.2rem;
}

h3.doc-heading {
font-size: 1.15rem;
}

h4.doc-heading {
font-size: 1.10rem;
}

h5.doc-heading {
font-size: 1.05rem;
}

h6.doc-heading {
font-size: 1rem;
}
Binary file added assets/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions assets/javascripts/bundle.d7c377c4.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions assets/javascripts/bundle.d7c377c4.min.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/javascripts/lunr/min/lunr.ar.min.js

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions assets/javascripts/lunr/min/lunr.da.min.js
18 changes: 18 additions & 0 deletions assets/javascripts/lunr/min/lunr.de.min.js
18 changes: 18 additions & 0 deletions assets/javascripts/lunr/min/lunr.du.min.js
1 change: 1 addition & 0 deletions assets/javascripts/lunr/min/lunr.el.min.js
18 changes: 18 additions & 0 deletions assets/javascripts/lunr/min/lunr.es.min.js
18 changes: 18 additions & 0 deletions assets/javascripts/lunr/min/lunr.fi.min.js
18 changes: 18 additions & 0 deletions assets/javascripts/lunr/min/lunr.fr.min.js
Loading

0 comments on commit 5c9c294

Please sign in to comment.