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

Feat: add logos #278

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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