Download page Using beautiful colors from the Atlassian Design System.
Using beautiful colors from the Atlassian Design System
Use case
You want to use beautiful colors from the Atlassian Design System to format cells' background conditionally: these colors will be automatically adjusted for Light and Dark Confluence themes.
Solution
Go to the Atlassian Design System and navigate to the Design Tokens section.
Locate the JavaScript syntax/CSS syntax dropdown menu at the top of the page and choose the CSS syntax option. Show the active tokens.
Copy the required color token and use it with the FORMATWIKI function inside the Table Transformer macro.
Switch the page to the edit mode.
Insert the Table Transformer macro and paste the table or the macros outputting tables within the macro body.
Select the macro and click Edit.
In the Presets tab select Custom transformation and click Next.
Enter the following SQL query:
SELECT *,
CASE
WHEN T1.'Amount of Transactions' < 30
THEN FORMATWIKI("{cell:background-color=var(--ds-background-accent-red-subtlest, red)}", T1.'Amount of Transactions', "{cell}")
WHEN T1.'Amount of Transactions' >= 30 AND T1.'Amount of Transactions' < 80
THEN FORMATWIKI("{cell:background-color=var(--ds-background-accent-yellow-subtlest, yellow)}", T1.'Amount of Transactions', "{cell}")
ELSE FORMATWIKI("{cell:background-color=var(--ds-background-accent-green-subtlest, green)}", T1.'Amount of Transactions', "{cell}")
END
AS 'Amount of Transactions'
FROM T*
The syntax for the FORMATWIKI function looks as following:
FORMATWIKI("{cell:background-color=var(--ds-background-accent-red-subtlest, red)}", T1.'Amount of Transactions', "{cell}")
Here the "--ds-background-accent-red-subtlest" part is a color token that we copy from the Atlassian Design System. The "red" part is an alternative Confluence color that is used by default (for example, if there is no such token in the system because you've copied the query to another instance with an old Confluence version).
Cookie Notice
This website uses cookies for analytics, personalization and advertising. By continuing to browse, you agree to our use of cookies. Learn more