Logos and Images

BrandLogoResource

BrandLogoResource(**data)

A logo resource, a file with optional alternative text

Attributes

Name Description
alt Alterative text for the image, used for accessibility.
attrs Additional attributes for HTML/markdown rendering.
path The path to the logo resource. This can be a local file or a URL.

Methods

Name Description
tagify Convenience method for .to_html(), for use in Shiny apps.
to_html Generate HTML img tag for the logo resource.
to_markdown Generate markdown image syntax for the logo resource.
to_str Convert logo resource to string representation.

tagify

BrandLogoResource.tagify()

Convenience method for .to_html(), for use in Shiny apps.

Returns

Name Type Description
htmltools.Tag HTML img tag as a string.

to_html

BrandLogoResource.to_html(**kwargs)

Generate HTML img tag for the logo resource.

Parameters

**kwargs: Any = {}

Additional HTML attributes to include in the img tag. Values should be compatible with htmltools.TagAttrValue types.

Returns

Name Type Description
htmltools.Tag HTML img tag as a string.

to_markdown

BrandLogoResource.to_markdown(**kwargs)

Generate markdown image syntax for the logo resource.

Parameters

**kwargs: Any = {}

Additional attributes to include in the markdown image syntax.

Returns

Name Type Description
str Markdown image syntax as a string.

to_str

BrandLogoResource.to_str(format_type='html', **kwargs)

Convert logo resource to string representation.

Parameters

format_type: str = ‘html’

Output format, either “html” or “markdown”.

**kwargs: Any = {}

Additional attributes for the output format.

Returns

Name Type Description
str String representation in the specified format.

BrandLightDark

BrandLightDark(**data)

A Light/Dark Variant

Holds variants for light and dark settings. Generally speaking light settings have white or light backgrounds and dark foreground colors (black text on a white page) and dark settings use black or dark background with light foreground colors (white text on a black page).

Attributes

Name Description
dark Value in dark mode.
light Value in light mode.

FileLocation

FileLocation(root=PydanticUndefined, **data)

The base class for a file location, either a local or an online file.

Local files are handled by brand_yml.file.FileLocationLocal and are always considered relative to the source _brand.yml file.

Online files are handled by brand_yml.file.FileLocationUrl and are a URL starting with https:// or http://. Absolute paths for local or network files are supported via FileLocationUrl when using the file:// prefix.

FileLocationLocal

FileLocationLocal(root=PydanticUndefined, **data)

A local file location.

When used in a brand_yml.Brand instance, this class carries both the relative path to the file, relative to the source _brand.yml, and the absolute path of the file on disk.

Methods

Name Description
absolute Absolute path of the file location, relative to the root directory.
exists Check that the file exists at its absolute path.
relative Relative path of the file location.
set_root_dir Update the root directory of this file location.
validate_exists Validate that the file exists at its absolute path.

absolute

FileLocationLocal.absolute()

Absolute path of the file location, relative to the root directory.

Returns the absolute path to the file, relative to the root directory, which is most typically the directory containing the _brand.yml file.

exists

FileLocationLocal.exists()

Check that the file exists at its absolute path.

relative

FileLocationLocal.relative()

Relative path of the file location.

Returns the relative path to the file as it would appear in the source _brand.yml file.

set_root_dir

FileLocationLocal.set_root_dir(root_dir)

Update the root directory of this file location.

In general, the root directory is the parent directory containing the source brand_yml file. If you relocate the file, this method can be used to update the new local file location.

validate_exists

FileLocationLocal.validate_exists()

Validate that the file exists at its absolute path.

Raises

Name Type Description
FileNotFoundError Raises a FileNotFoundError if the file does not exist at its absolute path location.

FileLocationUrl

FileLocationUrl(root=PydanticUndefined, **data)

A hosted, online file location, i.e. a URL.

A URL to a single file, typically an online file path starting with http:// or https://. This class can also be used for the absolute path of local or networked files, which should start with file:// (otherwise local files are handled by brand_yml.file.FileLocationLocal).

file.FileLocationLocalOrUrlType

file.FileLocationLocalOrUrlType

A type representing a file location that may be a local path or URL.