<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.funkystation.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACallout</id>
	<title>Module:Callout - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.funkystation.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACallout"/>
	<link rel="alternate" type="text/html" href="https://wiki.funkystation.org/index.php?title=Module:Callout&amp;action=history"/>
	<updated>2026-06-05T01:21:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.funkystation.org/index.php?title=Module:Callout&amp;diff=204&amp;oldid=prev</id>
		<title>imported&gt;Aliser: more robust &quot;align&quot; and banner mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.funkystation.org/index.php?title=Module:Callout&amp;diff=204&amp;oldid=prev"/>
		<updated>2024-09-02T06:51:15Z</updated>

		<summary type="html">&lt;p&gt;more robust &amp;quot;align&amp;quot; and banner mode&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {} --p stands for package&lt;br /&gt;
local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local itemModule = require(&amp;#039;Module:Item&amp;#039;)&lt;br /&gt;
local yesNo = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
-- =================&lt;br /&gt;
&lt;br /&gt;
local function assert_value_not_nil(value, error_message)&lt;br /&gt;
	if value == nil then&lt;br /&gt;
		if error_message == nil then&lt;br /&gt;
			error(&amp;quot;value is nil&amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			error(error_message)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- =================&lt;br /&gt;
&lt;br /&gt;
function p.generate_callout(frame)&lt;br /&gt;
    local args = getArgs(frame)&lt;br /&gt;
&lt;br /&gt;
	-- [REQUIRED]&lt;br /&gt;
	&lt;br /&gt;
	-- Callout type.&lt;br /&gt;
	local type = args[1]&lt;br /&gt;
    assert_value_not_nil(type, &amp;quot;failed to generate a callout: type was not provided&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
    -- Callout content.&lt;br /&gt;
    local content = args[2]&lt;br /&gt;
    assert_value_not_nil(content, &amp;quot;failed to generate a callout: content was not provided&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	-- [OPTIONAL]&lt;br /&gt;
&lt;br /&gt;
    -- Haeder. Can be `nil` - inferred from the type in that case.&lt;br /&gt;
    local header = args.header or args.h&lt;br /&gt;
&lt;br /&gt;
    -- Callout align.&lt;br /&gt;
    local align = string.lower(args.align or args.a or &amp;#039;left&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
    -- An image to add to the callout.&lt;br /&gt;
    local image1 = args.image or args.image1 or args.i&lt;br /&gt;
&lt;br /&gt;
    -- A second image to add to the callout.&lt;br /&gt;
    local image2 = args.image2 or args.i2&lt;br /&gt;
&lt;br /&gt;
    -- A flag for making compact, same-width callouts that can be stacked on top of each other.&lt;br /&gt;
    local stacked = yesNo(args.stacked or false)&lt;br /&gt;
&lt;br /&gt;
    -- A class to add to the wrapper element.&lt;br /&gt;
    local wrapper_class = args[&amp;quot;wrapper class&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
    -- [HARDCODED]&lt;br /&gt;
&lt;br /&gt;
    -- Default size of an image.&lt;br /&gt;
    local image_size = &amp;#039;80px&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    -- Width of the left thicc border.&lt;br /&gt;
    local strip_width = &amp;#039;10px&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    -- [AUTOCALCULATED]&lt;br /&gt;
&lt;br /&gt;
    -- When in this mode, the callout will span almost fully across the page.&lt;br /&gt;
    local in_banner_mode = align == &amp;quot;center&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	-- ============&lt;br /&gt;
&lt;br /&gt;
    local callout_wrapper_el = mw.html.create(&amp;quot;div&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout-wrapper&amp;quot;)&lt;br /&gt;
        :css(&amp;#039;justify-content&amp;#039;, align)&lt;br /&gt;
&lt;br /&gt;
    if stacked then&lt;br /&gt;
        callout_wrapper_el:addClass(&amp;quot;stacked-notice&amp;quot;);&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if(wrapper_class) then&lt;br /&gt;
        callout_wrapper_el:addClass(wrapper_class)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local type_lower = string.lower(type)&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    local callout_el = mw.html.create(&amp;quot;div&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout-type-&amp;quot; .. type_lower)&lt;br /&gt;
        :css(&amp;#039;--strip-size&amp;#039;, strip_width)&lt;br /&gt;
        :css(&amp;#039;clip-path&amp;#039;, &amp;quot;polygon(0 0, 100% 0, 100% 100%, calc(var(--strip-size) / 2) 100%, 0 calc(100% - var(--strip-size) / 2))&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if in_banner_mode then&lt;br /&gt;
        callout_el:addClass(&amp;quot;callout-banner&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    callout_wrapper_el:node(callout_el)&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
    local header_by_type&lt;br /&gt;
    if type_lower == &amp;#039;info&amp;#039; then&lt;br /&gt;
        header_by_type = &amp;#039;Info&amp;#039;&lt;br /&gt;
    elseif type_lower == &amp;#039;warning&amp;#039; then&lt;br /&gt;
        header_by_type = &amp;#039;Warning&amp;#039;&lt;br /&gt;
    elseif type_lower == &amp;#039;danger&amp;#039; then&lt;br /&gt;
        header_by_type = &amp;#039;Danger&amp;#039;&lt;br /&gt;
    elseif type_lower == &amp;#039;tip&amp;#039; then&lt;br /&gt;
        header_by_type = &amp;#039;Tip&amp;#039;&lt;br /&gt;
    elseif type_lower == &amp;#039;example&amp;#039; then&lt;br /&gt;
        header_by_type = &amp;#039;Example&amp;#039;&lt;br /&gt;
    else&lt;br /&gt;
        error(&amp;quot;failed to generate a callout: unknow callout type: &amp;quot; .. type)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- if header is unset, infer it from the type&lt;br /&gt;
    if header == nil then&lt;br /&gt;
        header = header_by_type&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    local callout_images_el = mw.html.create(&amp;quot;div&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout-images&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if image1 then&lt;br /&gt;
        callout_images_el:wikitext(&amp;quot;[[File:&amp;quot; .. image1 .. &amp;quot;|&amp;quot; .. image_size .. &amp;quot;]]&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if image2 then&lt;br /&gt;
        callout_images_el:wikitext(&amp;quot;[[File:&amp;quot; .. image2 .. &amp;quot;|&amp;quot; .. image_size .. &amp;quot;]]&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    callout_el:node(callout_images_el)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    local callout_header_content_container_el = mw.html.create(&amp;quot;div&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout-header-content-container&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    callout_el:node(callout_header_content_container_el)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    local callout_header = mw.html.create(&amp;quot;div&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout-header&amp;quot;)&lt;br /&gt;
        :node(header)&lt;br /&gt;
&lt;br /&gt;
    callout_header_content_container_el:node(callout_header)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    local callout_content_container = mw.html.create(&amp;quot;div&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout-content-container&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    callout_header_content_container_el:node(callout_content_container)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    local callout_content = mw.html.create(&amp;quot;div&amp;quot;)&lt;br /&gt;
        :addClass(&amp;quot;callout-content&amp;quot;)&lt;br /&gt;
        :node(content)&lt;br /&gt;
&lt;br /&gt;
    callout_content_container:node(callout_content)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    return callout_wrapper_el&lt;br /&gt;
        :allDone()&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Aliser</name></author>
	</entry>
</feed>