Skip to main content

Using components

We provide a few custom components that you can use inside documents.

To import a component, use an import statement from the component's description. Put the import on the top of a document, right before the main heading, and after doc metadata.

---
...
hide_title: true
---

{/* PUT IMPORTS HERE */}

# The document heading

Here's the list of our custom components.

Image​

Extended image component.

Importing:

import Image from '@site-comps/Image';
pubsrc(required) image source, just like <img> HTML tag.
pubborderWhether to add full page width border around image (default: false)
pubcenterWhether to center the image
pubdescA centered description displayed below the image
pubminwidthA convenient way to specify minWidth of the image."
pubwidthA convenient way to specify width of the image."
pubmaxwidthA convenient way to specify maxWidth of the image."
pubminheightA convenient way to specify minHeight of the image."
pubheightA convenient way to specify height of the image."
pubmaxheightA convenient way to specify maxHeight of the image."
Image component example
<Image center border
maxheight={200}
alt="Goblin enemy presentation"
src="/img/tutorials/course/basic/structures/GoblinEnemy.gif"
desc={<>Goblin image by <a href="https://luizmelo.itch.io/monsters-creatures-fantasy">LuizMelo</a></>}
/>

Result:


Goblin enemy presentation
Goblin image by LuizMelo

Columns​

Splits children into columns.

Importing:

import Columns from '@site-comps/Columns';
pubcolumns(required) CSS column widths (array), see example below.
Columns component example
<Columns columns={["8fr", "4fr"]}>
<div>Contents of column 1</div>
<div>Contents of column 2</div>
</Columns>
tip

Columns component are often used to display code alongside its result.

You can use a prepared "coderesult" snippet I've put in .vscode-template.

Known issues:

  • column widths are not responsive

CustomCodeBlock​

Adds additional functionality to markdown code blocks.

Importing:

import CustomCodeBlock from '@site-comps/CustomCodeBlock';
pubmaxLinesNumber of lines that when exceeded, causes a vertical scrollbar to appear.
pubresizableWhether user should be able to resize code block

Changelog:

  • Removed lineNumbers - Docusaurus now natively supports showLineNumbers in Markdown code block

Known issues:

  • user can resize beyond the height of the code block

GoogleSlides​

Embeds a Google Slides presentation.

Importing:

import GoogleSlides from '@site-comps/GoogleSlides';
pubsrc(required) The source of a Google Slides presentation (cut after /embed)
pubaspectRatioA number that describes width : height ratio (default: 16 / 9)
pubdelayInterval between automatic slide changes (milliseconds)
pubautoStartWhether to start the presentation after page load (default: true)
publoopWhether to loop the presentation (default: true)
pubfullWidthWhether to use 100% (true) of page width or 80% (false) (default: false)

Example:

<GoogleSlides
src="https://docs.google.com/presentation/d/e/2PACX-1vTsdQPMXKN90rcz4i515JK-rpUHjHTc5xIjGVtNJS8XSbloMNObHEBUSszvYi9I7tuKBNIdEKNFh1jk/embed"
aspectRatio={960 / 500}
delay={500}
centered
/>

Result:



SymbolTable​

A table that is used to document symbols and properties.

Importing:

import SymbolTable, { Symbol } from '@site-comps/SymbolTable';

SymbolTable fields​

pubnoTraitsWhether to hide the left-most column with symbol traits (const, static, etc.)

Symbol fields​

pubname(required) Name of the symbol
pubdesc

Description of the symbol. You can also specify it as a children:

<Symbol name="symbol">
This will be considered a description
</Symbol>
caution

Due to rules of MDX formatter, if you want to use Markdown elements inside the JSX element, you have to remove the indentation, otherwise it will be recognized as a code block.

pubautoLinkAuto-generate the link
publinkCustom link
publinkNameURL-compliant name used when autoLink=true

Symbol trait fields:​

pubpubAdds a "public" trait to the symbol
pubprivAdds a "private" trait to the symbol
pubprotAdds a "protected" trait to the symbol
pubvolatileAdds a "volatile" trait to the symbol
pubconstAdds a "const" trait to the symbol
pubconstexprAdds a "constexpr" trait to the symbol
pubvirtualAdds a "virtual" trait to the symbol
pubstaticAdds a "static" trait to the symbol

ClassSummary​

Importing:

import ClassSummary from "@site-comps/ClassSummary";

Usage:

import ClassSummary				from '@site-comps/ClassSummary';
import SymbolTable, { Symbol } from '@site-comps/SymbolTable';

<ClassSummary name="string" namespaces="std">

### Methods

<SymbolTable>
<Symbol pub autoLink name="contains" desc="Checks if the string contains the given substring or character"/>
<Symbol pub autoLink name="substr" desc="Returns a substring"/>
<Symbol pub autoLink name="empty">
Returns <code>true</code> if the string is empty, otherwise <code>false</code>.
</Symbol>
</SymbolTable>

</ClassSummary>

Result:

Class Summary

ClassSummary Fields​

pubname(required) The name of the class
pubnamespacesA string, or a list of namespaces, for example:
namespaces="std" or namespaces={["std", "chrono"]}

ProductCard​

Importing:

import ProductCard from '@site-comps/ProductCard';

Usage:

<ProductCard title="Visual Studio Code" author="Microsoft" img="/img/icons/products/vscode_1_35.svg" rating={9}>
<ProductCard.Desc>
A powerful tool with everything you need, including a code editor
and a compiler that supports the latest C++20 standard.
<ProductCard.Details>
<h3>Pros</h3>
<ul>
<li>All in one</li>
<li>Simple installation and configuration</li>
<li>Access to the latest C++20 standard</li>
<li>The best debugger available</li>
</ul>
<h3>Cons</h3>
<ul>
<li>Relatively big installation size (download ~2 GB, after installation ~7 GB)</li>
<li>Not portable</li>
<li>Windows only</li>
</ul>
</ProductCard.Details>
</ProductCard.Desc>
<ProductCard.Actions>
<a href="https://code.visualstudio.com">Product website</a>
</ProductCard.Actions>
</ProductCard>

Result:

Product icon

Visual Studio Code (Microsoft)

A powerful tool with everything you need, including a code editor and a compiler that supports the latest C++20 standard.

Details

Pros

  • All in one
  • Simple installation and configuration
  • Access to the latest C++20 standard
  • The best debugger available

Cons

  • Relatively big installation size (download ~2 GB, after installation ~7 GB)
  • Not portable
  • Windows only

ProductCard Fields​

pubtitle(required) The name of the class
pubimg(required) A string containing an URL of an image, or a SVG element
pubauthorThe author of the product
pubratingThe rating of the product, showed using 5-stars. Use values between 0 and 10.

ProductCard.Desc​

It is a subcomponent of the ProductCard used to add the product's description.

ProductCard.Actions​

It is a subcomponent of the ProductCard used to add actions content to the product.

ProductCard.Details​

It is a subcomponent of the ProductCard used to add details to the product's description.

caution

ProductCard.Details is only allowed inside a ProductCard.Desc element.

ToolCard​

Importing:

import ToolCard from '@site-comps/ToolsSummary';
caution

TODO: description

Using components

We provide a few custom components that you can use inside documents.

To import a component, use an import statement from the component's description. Put the import on the top of a document, right before the main heading, and after doc metadata.

---
...
hide_title: true
---

{/* PUT IMPORTS HERE */}

# The document heading

Here's the list of our custom components.

Image​

Extended image component.

Importing:

import Image from '@site-comps/Image';
pubsrc(required) image source, just like <img> HTML tag.
pubborderWhether to add full page width border around image (default: false)
pubcenterWhether to center the image
pubdescA centered description displayed below the image
pubminwidthA convenient way to specify minWidth of the image."
pubwidthA convenient way to specify width of the image."
pubmaxwidthA convenient way to specify maxWidth of the image."
pubminheightA convenient way to specify minHeight of the image."
pubheightA convenient way to specify height of the image."
pubmaxheightA convenient way to specify maxHeight of the image."
Image component example
<Image center border
maxheight={200}
alt="Goblin enemy presentation"
src="/img/tutorials/course/basic/structures/GoblinEnemy.gif"
desc={<>Goblin image by <a href="https://luizmelo.itch.io/monsters-creatures-fantasy">LuizMelo</a></>}
/>

Result:


Goblin enemy presentation
Goblin image by LuizMelo

Columns​

Splits children into columns.

Importing:

import Columns from '@site-comps/Columns';
pubcolumns(required) CSS column widths (array), see example below.
Columns component example
<Columns columns={["8fr", "4fr"]}>
<div>Contents of column 1</div>
<div>Contents of column 2</div>
</Columns>
tip

Columns component are often used to display code alongside its result.

You can use a prepared "coderesult" snippet I've put in .vscode-template.

Known issues:

  • column widths are not responsive

CustomCodeBlock​

Adds additional functionality to markdown code blocks.

Importing:

import CustomCodeBlock from '@site-comps/CustomCodeBlock';
pubmaxLinesNumber of lines that when exceeded, causes a vertical scrollbar to appear.
pubresizableWhether user should be able to resize code block

Changelog:

  • Removed lineNumbers - Docusaurus now natively supports showLineNumbers in Markdown code block

Known issues:

  • user can resize beyond the height of the code block

GoogleSlides​

Embeds a Google Slides presentation.

Importing:

import GoogleSlides from '@site-comps/GoogleSlides';
pubsrc(required) The source of a Google Slides presentation (cut after /embed)
pubaspectRatioA number that describes width : height ratio (default: 16 / 9)
pubdelayInterval between automatic slide changes (milliseconds)
pubautoStartWhether to start the presentation after page load (default: true)
publoopWhether to loop the presentation (default: true)
pubfullWidthWhether to use 100% (true) of page width or 80% (false) (default: false)

Example:

<GoogleSlides
src="https://docs.google.com/presentation/d/e/2PACX-1vTsdQPMXKN90rcz4i515JK-rpUHjHTc5xIjGVtNJS8XSbloMNObHEBUSszvYi9I7tuKBNIdEKNFh1jk/embed"
aspectRatio={960 / 500}
delay={500}
centered
/>

Result:



SymbolTable​

A table that is used to document symbols and properties.

Importing:

import SymbolTable, { Symbol } from '@site-comps/SymbolTable';

SymbolTable fields​

pubnoTraitsWhether to hide the left-most column with symbol traits (const, static, etc.)

Symbol fields​

pubname(required) Name of the symbol
pubdesc

Description of the symbol. You can also specify it as a children:

<Symbol name="symbol">
This will be considered a description
</Symbol>
caution

Due to rules of MDX formatter, if you want to use Markdown elements inside the JSX element, you have to remove the indentation, otherwise it will be recognized as a code block.

pubautoLinkAuto-generate the link
publinkCustom link
publinkNameURL-compliant name used when autoLink=true

Symbol trait fields:​

pubpubAdds a "public" trait to the symbol
pubprivAdds a "private" trait to the symbol
pubprotAdds a "protected" trait to the symbol
pubvolatileAdds a "volatile" trait to the symbol
pubconstAdds a "const" trait to the symbol
pubconstexprAdds a "constexpr" trait to the symbol
pubvirtualAdds a "virtual" trait to the symbol
pubstaticAdds a "static" trait to the symbol

ClassSummary​

Importing:

import ClassSummary from "@site-comps/ClassSummary";

Usage:

import ClassSummary				from '@site-comps/ClassSummary';
import SymbolTable, { Symbol } from '@site-comps/SymbolTable';

<ClassSummary name="string" namespaces="std">

### Methods

<SymbolTable>
<Symbol pub autoLink name="contains" desc="Checks if the string contains the given substring or character"/>
<Symbol pub autoLink name="substr" desc="Returns a substring"/>
<Symbol pub autoLink name="empty">
Returns <code>true</code> if the string is empty, otherwise <code>false</code>.
</Symbol>
</SymbolTable>

</ClassSummary>

Result:

Class Summary

ClassSummary Fields​

pubname(required) The name of the class
pubnamespacesA string, or a list of namespaces, for example:
namespaces="std" or namespaces={["std", "chrono"]}

ProductCard​

Importing:

import ProductCard from '@site-comps/ProductCard';

Usage:

<ProductCard title="Visual Studio Code" author="Microsoft" img="/img/icons/products/vscode_1_35.svg" rating={9}>
<ProductCard.Desc>
A powerful tool with everything you need, including a code editor
and a compiler that supports the latest C++20 standard.
<ProductCard.Details>
<h3>Pros</h3>
<ul>
<li>All in one</li>
<li>Simple installation and configuration</li>
<li>Access to the latest C++20 standard</li>
<li>The best debugger available</li>
</ul>
<h3>Cons</h3>
<ul>
<li>Relatively big installation size (download ~2 GB, after installation ~7 GB)</li>
<li>Not portable</li>
<li>Windows only</li>
</ul>
</ProductCard.Details>
</ProductCard.Desc>
<ProductCard.Actions>
<a href="https://code.visualstudio.com">Product website</a>
</ProductCard.Actions>
</ProductCard>

Result:

Product icon

Visual Studio Code (Microsoft)

A powerful tool with everything you need, including a code editor and a compiler that supports the latest C++20 standard.

Details

Pros

  • All in one
  • Simple installation and configuration
  • Access to the latest C++20 standard
  • The best debugger available

Cons

  • Relatively big installation size (download ~2 GB, after installation ~7 GB)
  • Not portable
  • Windows only

ProductCard Fields​

pubtitle(required) The name of the class
pubimg(required) A string containing an URL of an image, or a SVG element
pubauthorThe author of the product
pubratingThe rating of the product, showed using 5-stars. Use values between 0 and 10.

ProductCard.Desc​

It is a subcomponent of the ProductCard used to add the product's description.

ProductCard.Actions​

It is a subcomponent of the ProductCard used to add actions content to the product.

ProductCard.Details​

It is a subcomponent of the ProductCard used to add details to the product's description.

caution

ProductCard.Details is only allowed inside a ProductCard.Desc element.

ToolCard​

Importing:

import ToolCard from '@site-comps/ToolsSummary';
caution

TODO: description