Skip to content

Commit

Permalink
Feat: add logos (#278)
Browse files Browse the repository at this point in the history
* fix #276

* feat: updated logo
  • Loading branch information
julio4 authored Dec 17, 2024
1 parent 273e2a6 commit 682da84
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 6 deletions.
27 changes: 27 additions & 0 deletions components/ThemeImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useEffect, useState } from "react";
import { useTheme } from "./useTheme";

export const ThemeImage = ({
light,
dark,
alt,
...props
}: {
light: string;
dark: string;
alt: string;
[key: string]: any;
}) => {
const [mounted, setMounted] = useState(false);
const theme = useTheme();

useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return <img src={light} alt={alt} {...props} />;
}

// Client-side rendering after hydrating
return <img src={theme === "light" ? light : dark} alt={alt} {...props} />;
};
32 changes: 32 additions & 0 deletions components/useTheme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useEffect, useState } from "react";

export function useTheme() {
const [theme, setTheme] = useState<"dark" | "light">(() => {
if (typeof window === "undefined") return "light";
return document.documentElement.classList.contains("dark")
? "dark"
: "light";
});

useEffect(() => {
const handleThemeChange = () => {
const newTheme = document.documentElement.classList.contains("dark")
? "dark"
: "light";
setTheme(newTheme);
};

// Watch for class changes on documentElement
const observer = new MutationObserver(handleThemeChange);
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ["class"],
});

return () => {
observer.disconnect();
};
}, []);

return theme;
}
3 changes: 0 additions & 3 deletions pages/getting-started/testing/contract-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ Now, let's move on to the testing process:
- Use `assert` to verify that the contract behaves as expected in the given context
- You can also use assertion macros: `assert_eq!`, `assert_ne!`, `assert_gt!`, `assert_ge!`, `assert_lt!`, `assert_le!`

If you haven't noticed yet, every example in this book has hidden tests, you can see them by clicking the "Show hidden lines" (eyes icon) on the top right of code blocks.
You can also find a detailed explanation of testing in Cairo in [The Cairo Book](https://book.cairo-lang.org/ch10-00-testing-cairo-programs.html).

## Using the contract state

You can use the `Contract::contract_state_for_testing` function to access the contract state. This function is only available in the test environment and allows you to mutate and read the contract state directly.
Expand Down
9 changes: 9 additions & 0 deletions pages/index.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Sponsors } from "vocs/components";
import { ThemeImage } from "../components/ThemeImage";

<div className="flex justify-center">
<ThemeImage
light="/svg/Vertical_Light.svg"
dark="/svg/Vertical_Dark.svg"
alt="Starknet By Example"
/>
</div>

# Introduction

Expand Down
29 changes: 29 additions & 0 deletions public/svg/Horizontal_Dark.svg
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 public/svg/Horizontal_Light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/svg/Icon_Dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/svg/Icon_Light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 682da84

Please sign in to comment.