-
Notifications
You must be signed in to change notification settings - Fork 298
chore(developer-hub): dual image mode enable and use in OIS #3055
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,20 @@ description: >- | |
This reference page provides examples of various scenarios to illustrate the Mathematical Representations of OIS. | ||
--- | ||
|
||
import DualModeImage from "../../../src/components/DualModeImage"; | ||
|
||
NOTE: All the symbols used in the examples are explained in the [Mathematical Representation](./mathematical-representation) section. | ||
|
||
## Example 1: Only Publisher Stake | ||
|
||
This example takes the case of one pool where the pool has stake from only the publisher. | ||
|
||
 | ||
<br /> | ||
<DualModeImage | ||
darkSrc="/images/ois/OIS_Rewards_Example_Dark_1.png" | ||
lightSrc="/images/ois/OIS_Rewards_Example_Light_1.png" | ||
alt="Example 1 - Only Publisher Stake" | ||
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per the fuma docs, referencing Images with URL |
||
/> | ||
|
||
$$ | ||
\begin{aligned} | ||
|
@@ -33,7 +40,12 @@ $$ | |
|
||
This example takes the case where the pool has stake from both the publisher and the delegator. | ||
|
||
 | ||
<br /> | ||
<DualModeImage | ||
darkSrc="/images/ois/OIS_Rewards_Example_Dark_2.png" | ||
lightSrc="/images/ois/OIS_Rewards_Example_Light_2.png" | ||
alt="Example 2 - Publisher and Delegator Stake" | ||
/> | ||
|
||
$$ | ||
\begin{aligned} | ||
|
@@ -56,7 +68,12 @@ $$ | |
|
||
This example takes the case where the combined stake of both the publisher and the delegator exceeds the cap. | ||
|
||
 | ||
<br /> | ||
<DualModeImage | ||
darkSrc="/images/ois/OIS_Rewards_Example_Dark_3.png" | ||
lightSrc="/images/ois/OIS_Rewards_Example_Light_3.png" | ||
alt="Example 3 - Stake Exceeding Cap" | ||
/> | ||
|
||
$$ | ||
\begin{aligned} | ||
|
@@ -79,7 +96,12 @@ $$ | |
|
||
This example demonstrates how the delegation fee affect the reward distribution between the publisher and the delegator. | ||
|
||
 | ||
<br /> | ||
<DualModeImage | ||
darkSrc="/images/ois/OIS_Rewards_Example_Dark_4.png" | ||
lightSrc="/images/ois/OIS_Rewards_Example_Light_4.png" | ||
alt="Example 4 - Delegator Fees" | ||
/> | ||
|
||
$$ | ||
\begin{aligned} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
apps/developer-hub/src/components/DualModeImage/index.module.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.lightImage { | ||
display: block; | ||
|
||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. created this module, and added them in a folder to follow the same pattern. |
||
:global(.dark) & { | ||
display: none; | ||
} | ||
} | ||
|
||
.darkImage { | ||
display: none; | ||
|
||
:global(.dark) & { | ||
display: block; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import clsx from "clsx"; | ||
import { ImageZoom } from "fumadocs-ui/components/image-zoom"; | ||
import Image from "next/image"; | ||
import type { ComponentProps } from "react"; | ||
|
||
import styles from "./index.module.scss"; | ||
|
||
type ImageProps = ComponentProps<typeof Image>; | ||
type Props = Omit<ImageProps, "src"> & { | ||
darkSrc: string; | ||
lightSrc: string; | ||
}; | ||
|
||
const DualModeImage = ({ | ||
darkSrc, | ||
lightSrc, | ||
className, | ||
alt, | ||
width = 800, | ||
height = 600, | ||
sizes = "100vw", | ||
...props | ||
}: Props) => { | ||
const commonProps = { | ||
alt, | ||
width, | ||
height, | ||
sizes, | ||
...props, | ||
}; | ||
|
||
return ( | ||
<> | ||
<ImageZoom | ||
src={lightSrc} | ||
className={clsx(styles.lightImage, className)} | ||
{...commonProps} | ||
/> | ||
<ImageZoom | ||
src={darkSrc} | ||
className={clsx(styles.darkImage, className)} | ||
{...commonProps} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default DualModeImage; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to import the images and pass the import here. Next can do some automatic image optimization when you import images which it cannot do when you use image urls. Also you can colocate the images with where they're used which is nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I was using image URL as per the fuma docs https://fumadocs.dev/docs/headless/custom-source#images
If there would be optimization by using the import, lets do it.