home readme diff tree note docs

0commit 1b6596168bd0697fe5615799a5e6e2dbc777bf1c
1Author: Mason Wright <mason@lakefox.net>
2Date:   Sun Aug 3 15:34:04 2025 -0600
3
4    Starting media queries and at-rules
5
6diff --git a/docs/components/navbar.html b/docs/components/navbar.html
7new file mode 100644
8index 0000000..666d5d0
9--- /dev/null
10+++ b/docs/components/navbar.html
11@@ -0,0 +1,23 @@
12+<aside style="min-width: 200px">
13+	<img src="/logo.webp"/ width="150px">
14+	<ul>
15+		<li>
16+			<strong><a href="/">Home</a></strong>
17+		</li>
18+	</ul>
19+	<details open>
20+		<summary>Links</summary>
21+		<ul>
22+			<li><a href="https://src.grimui.com">Source</a></li>
23+			<li><a href="https://tracker.grimui.com">Trackers</a></li>
24+		</ul>
25+	</details>
26+	<details open>
27+		<summary>Feature Support</summary>
28+		<ul>
29+			<li><a href="/features/supported-css-selectors.html">CSS Selectors</a></li>
30+			<li><a href="/features/supported-html-tags.html">HTML Tags</a></li>
31+			<li><a href="/features/supported-dom-apis.html">DOM APIs</a></li>
32+		</ul>
33+	</details>
34+</aside>
35diff --git a/docs/content/logo.webp b/docs/content/logo.webp
36deleted file mode 100755
37index f8806a8..0000000
38Binary files a/docs/content/logo.webp and /dev/null differ
39diff --git a/docs/public/logo.webp b/docs/public/logo.webp
40deleted file mode 100755
41index f8806a8..0000000
42Binary files a/docs/public/logo.webp and /dev/null differ
43diff --git a/docs/template.html b/docs/template.html
44new file mode 100644
45index 0000000..8d8a7ed
46--- /dev/null
47+++ b/docs/template.html
48@@ -0,0 +1,36 @@
49+<!DOCTYPE html>
50+<html lang="en">
51+	<head>
52+		<meta charset="UTF-8" />
53+		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
54+		<title>GrimUI</title>
55+		<style>
56+body {
57+	margin-bottom: 100px;
58+}
59+table {
60+      width: 100%;
61+      border-collapse: collapse;
62+}
63+th,
64+td {
65+      text-align: center;
66+      border: 1px solid #ddd;
67+      padding: 8px;
68+}
69+th {
70+      background-color: #f2f2f2;
71+}
72+		</style>
73+	</head>
74+	<body>
75+		<main style="margin: 0 4rem 0 4rem">
76+			<div style="display: flex; gap: 1rem">
77+				$V1
78+				<div style="width: 100%">
79+					<section>$V2</section>
80+				</div>
81+			</div>
82+		</main>
83+	</body>
84+</html>
85diff --git a/include/grim.h b/include/grim.h
86index 09a4fcf..0d8490a 100644
87--- a/include/grim.h
88+++ b/include/grim.h
89@@ -12,9 +12,9 @@
90 #include <optional>
91 #include <stdexcept>
92 
93-// !TODO: At rules
94-// + Document object
95-// + templates
96+// TODO:
97+// * Document object
98+// * templates
99 
100 class Attribute {
101 	private:
102@@ -145,13 +145,30 @@ std::vector<std::vector<std::string>> parseSelectorParts(std::string_view);
103 
104 bool testSelector(Node*, std::vector<std::vector<std::string>>);
105 
106+struct Environment {
107+	int width;
108+	int height;
109+};
110+
111 struct Style {
112 	std::unordered_map<std::string, std::string> properties;
113 	std::vector<std::vector<std::string>> selector;
114 	size_t index;
115 };
116 
117-class StyleHandler {
118+enum SheetType {
119+	LAYER,
120+	CONTAINER,
121+	COUNTER,
122+	FONT,
123+	IMPORT,
124+	NAMESPACE,
125+	PAGE,
126+	PROPERTY,
127+	STARTINGSTYLE
128+};
129+
130+class StyleSheet {
131 	private:
132 		// basemap: Maps baseparts to a index of the styles vector pointing to a Style object
133 		// because processing a CSS selector isn't trivial we want to make a short list of 
134@@ -163,7 +180,35 @@ class StyleHandler {
135 		// or what ever else the selector needs to match.
136 		std::unordered_map<std::string, std::vector<size_t>> basemap;
137 		std::vector<Style> styles;
138-		
139+
140+	public:
141+		std::string name;
142+		std::string path;
143+		query query;
144+		SheetType type;
145+
146+
147+		void add(std::string selector, std::unordered_map<std::string, std::string> properties);
148+};
149+
150+struct AtRule {
151+	std::string identifier;
152+	std::string rule;
153+	// How to capture the data inside a block?
154+	// it could be anything that can be in a style sheet
155+	// basically need to parse a @rule like a seperate stylesheet
156+	// then merge when a condition is meant if its applicable
157+	//
158+	// if linked a shared document pointer then each should be able to 
159+	// report if applies. the main one should be the same as the rest
160+	
161+	// this will be a circular reference kinda
162+	StyleSheet styleSheet;
163+};
164+
165+class StyleHandler {
166+	private:
167+				
168 		std::vector<std::string> parseNodeParts(Node* node);
169 		/*
170 		// At rules: should be querable, these will apply over the getStyles if they apply
171@@ -183,7 +228,7 @@ class StyleHandler {
172 		};*/
173 
174 	public:
175-		void add(std::string selector, std::unordered_map<std::string, std::string> properties);
176+		
177 		
178 		std::unordered_map<std::string, std::string> getStyles(Node* node);
179 
180@@ -192,6 +237,69 @@ class StyleHandler {
181 		// make a function that will return a list of attributes the will cause style changes if set
182 };
183 
184+class Window {
185+	private:
186+		int width = 0;
187+		int height = 0;
188+		int resolution = 0;
189+		std::string anyHover = "hover";
190+		std::string anyPointer = "fine";
191+		std::string orientation = "landscape";
192+		std::string colorScheme = "light";
193+		std::string contrast = "no-preference";
194+		std::string reducedMotion = "no-preference";
195+		std::string reducedTransparency = "no-preference";
196+		std::string update = "fast";
197+	public:
198+		void setWidth(int value) {
199+			width = value;
200+		}
201+		void setHeight(int value) {
202+			height = value;
203+		}
204+		void setResolution(int value) {
205+			resolution = value;
206+		}
207+		void setMouse(std::string pointer) {
208+			if (pointer == "none") {
209+				anyHover = "none";
210+			} else {
211+				anyHover = "hover";
212+			}
213+
214+			anyPointer = pointer;
215+		}
216+		void setOrientation(std::string value) {
217+			orientation = value;
218+		}
219+		void setColorScheme(std::string value) {
220+			colorScheme = value;
221+		}
222+		void setContrast(std::string value) {
223+			contrast = value;
224+		}
225+		void setReducedMotion(std::string value) {
226+			reducedMotion = value;
227+		}
228+		void setReducedTransparency(std::string value) {
229+			reducedTransparency = value;
230+		}
231+		void setUpdate(std::string value) {
232+			update = value;
233+		}
234+		
235+		
236+
237+		int getWidth() {
238+			return width;
239+		}
240+		int getHeight() {
241+			return height;
242+		}
243+		double getAspectRatio() {
244+			return width/height;
245+		}
246+};
247 
248 
249 #endif // NODE_H
250diff --git a/src/grim.cc b/src/grim.cc
251index 846449f..2988bcf 100755
252--- a/src/grim.cc
253+++ b/src/grim.cc
254@@ -695,6 +695,8 @@ void StyleHandler::add(std::string selector, std::unordered_map<std::string, std
255 }
256 		
257 std::unordered_map<std::string, std::string> StyleHandler::getStyles(Node* node) {
258+	// TODO: Will need to change getStyles to first consider if the style sheet applies
259+	// then to check the selectors
260 	std::vector<std::string> parts = parseNodeParts(node);
261 
262 	std::vector<size_t> canidates;
263diff --git a/tests/css_parser.cc b/tests/css_parser.cc
264index 1913211..8470cc1 100644
265--- a/tests/css_parser.cc
266+++ b/tests/css_parser.cc
267@@ -159,7 +159,7 @@ html#nested {
268 
269 	std::unique_ptr<StyleHandler> handler = parseCSS(inputFile);
270 	SECTION("StyleHandler Benchmark") {
271-		BENCHMARK("style.css") {
272+		BENCHMARK("master.css") {
273 			std::ifstream tempFile("./tests/master.css");
274 			return parseCSS(tempFile);
275 		};