Skip to content
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
9 changes: 7 additions & 2 deletions website/docs/foundations/diamond-contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Diamond Contracts
description: "Understand Diamonds from the ground up—facets, storage, delegation, and how Compose uses them."
---

import DiamondFacetsSVG from '@site/static/img/svg/compose_diamond_facets.svg'
import SvgThemeRenderer from '@site/src/components/theme/SvgThemeRenderer';

A **diamond contract** is a smart contract that is made up of multiple parts instead of one large block of code. The diamond exists at **one address** and holds **all of the contract's storage**, but it uses separate smart contracts called **facets** to provide its functionality.

Expand All @@ -23,7 +23,12 @@ A diamond has:

Below is a diagram showing a diamond with multiple facets.

<DiamondFacetsSVG style={{ maxWidth: '100%', height: 'auto' }} />
<SvgThemeRenderer
lightSrc={"/img/svg/diamond-diagram-light.svg"}
darkSrc={"/img/svg/diamond-diagram-dark.svg"}
alt="Diagram showing how facets compose into a diamond contract"
style={{ maxWidth: '100%', height: 'auto' }}
/>

A Diamond lets you:

Expand Down
3 changes: 3 additions & 0 deletions website/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ export { default as NavbarEnhancements } from './navigation/NavbarEnhancements';
export { default as NavbarGradient } from './navigation/NavbarGradient';
export { default as GitHubStarButton } from './navigation/GitHubStarButton';

// Theme Components
export { default as SvgThemeRenderer } from './theme/SvgThemeRenderer';

41 changes: 41 additions & 0 deletions website/src/components/theme/SvgThemeRenderer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import clsx from 'clsx';
import {useColorMode} from '@docusaurus/theme-common';

/**
* SvgThemeRenderer Component
*
* @param {string} lightSrc - Path to the SVG to display in light mode
* @param {string} darkSrc - Path to the SVG to display in dark mode
* @param {string} alt - Accessible description for the SVG image
* @param {string} className - Optional className for the root element
* @param {object} props - Additional img element props (style, loading, etc.)
*/
export default function SvgThemeRenderer({
lightSrc,
darkSrc,
alt = '',
className,
...props
}) {

const {colorMode} = useColorMode();

const activeSrc =
colorMode === 'dark'
? darkSrc || lightSrc
: lightSrc || darkSrc;

if (!activeSrc) {
return null;
}

return (
<img
src={activeSrc}
alt={alt}
className={clsx(className)}
{...props}
/>
);
}
5 changes: 5 additions & 0 deletions website/static/img/svg/diamond-diagram-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions website/static/img/svg/diamond-diagram-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.