Configurable colour of a title in Expand macro

Hi,

I need to have different colours of title in the expand function. I should be able to change the colour of the title to red, green, yellow, purple, blue etc.

How can I do that?

I can't find any macros that can do that.

2 answers

0 vote
Davin Studer Community Champion Oct 03, 2014

Here is a user macro that does what you are wanting. You might want to fill out the style section a bit (padding, border, border-radius, etc). I've used the same colors that are used in the status macro for consistency.

Macro Name:
color_expand

Macro Title:
Color Expand 

Description:
Embeds an expandable text box into your page. 

Documentation URL:
http://confluence.atlassian.com/display/DOC/Expand+Macro 

Macro Body Processing:
Rendered

Template:

## Developed by: My Name
## Date created: dd/mm/yyyy
## Installed by: My Name
## @param title:title=Title|type=string|default=Click here to expand...|desc=
## @param color:title=Title Background Color|type=enum|enumValues=grey,red,yellow,green,blue|desc=
##############################
## Create a unique id value ##
##############################
#set( $id=$action.dateFormatter.calendar.timeInMillis )
#if ($paramcolor == "grey")
    #set ($backColor = "#CCCCCC")
    #set ($textColor = "#3B73AF")
#elseif ($paramcolor == "red")
    #set ($backColor = "#D04437")
    #set ($textColor = "#FFFFFF")
#elseif ($paramcolor == "yellow")
    #set ($backColor = "#FFD351")
    #set ($textColor = "#3B73AF")
#elseif ($paramcolor == "green")
    #set ($backColor = "#14892C")
    #set ($textColor = "#FFFFFF")
#elseif ($paramcolor == "blue")
    #set ($backColor = "#4A6785")
    #set ($textColor = "#FFFFFF")
#else
    #set ($backColor = "transparent")
    #set ($textColor = "#3B73AF")
#end

<style type="text/css">
#exp_cnt_$id .expand-control-text {
    background: $backColor;
    color: $textColor;
}
</style>
<div id="exp_cnt_$id">
    <ac:structured-macro ac:name="expand">
        #if($!paramtitle && $!paramtitle != "")
        <ac:parameter ac:name="title">$!paramtitle</ac:parameter>
        #end
        <ac:rich-text-body>
            $body
        </ac:rich-text-body>
    </ac:structured-macro>
</div>

Hi Davin, Thank you very much. Can you please help me again. I am not sure how much of the text/code I should add in the User Macro (Definition of User Macro > Template)? And when I am in WIKI Markup, which code should I write to get the function work right? What I need is this: (example with normal expand) to get af normal expand-function without colors i write: {expand:title=Title here} Text text text {expand} Thank you in advance.

Davin Studer Community Champion Oct 06, 2014

I edited my original user macro a bit(to fix a typo), so use the new one. When you are in the user maco definition the code block above is the template. Everything in that code block is part of the template. The stuff above the code block is for the other field in the user macro setup. As for wiki markup you would user this. {color_expand:title=Stuff|color=red} Blah {color_expand}

Hi Davin,

Thank you very much.

Can you please help me again.

I am not sure how much of the text/code I should add in the User Macro (Definition of User Macro > Template)? And when I am in WIKI Markup, which code should I write to get the function work right?

What I need is this:
(example with normal expand)

to get af normal expand-function without colors i write:

{expand:title=Title here}
Text text text
{expand}

 

Thank you in advance.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,769 views 26 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you