Skip to content

Per-page default option values for directives #80

Description

@choldgraf

Context

There are many times where you want to populate a single page with many Sphinx Design items that all share the same configuration. For example, "I want a list of 10 cards, each of which has a specific margin, padding, outline, or CSS class".

In these cases, there is a lot of toil and boilerplate duplication when adding them, since you have to manually edit the options for each one. It would be helpful if there were a way to define the default configuration of each item once and then re-use it throughout the page.

Proposal

Make it possible to define the default configuration of Sphinx Design components on a per-page level (or at the site-level). There are two ways I could think of to do this:

  1. Use page-level configuration. For example:

    sphinx_design:
       defaults:
          link-button:
     	    :color: primary
     		:outline:
    

    However I don't know that this would be doable in rST...

  2. Set page-level defaults with a directive. For example, perhaps there was a sd-default directive. Inside that directive you could define any arbitrary Sphinx Design objects. It would render them as normal, but would also then set the configuration of each object to be the default for any subsequent objects on the page. e.g.:

    ````{sd-default}
    ```{button-link} foo
    :color: primary
    :outline:
    ```
    ````
    

Tasks and updates

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions