README
1NAME
2 Color::Theme::Role - Role for class wanting to support color themes
3
4VERSION
5 This document describes version 0.020 of Color::Theme::Role (from Perl
6 distribution Color-Theme-Role), released on 2018-02-25.
7
8DESCRIPTION
9 This role is for class that wants to support color themes. Color theme
10 is represented as a structure according to the specification described
11 in Color::Theme.
12
13 Color theme module. Color themes are put in modules under
14 "Color::Theme::Themes::" (configurable using "color_theme_module_prefix"
15 attribute). Each color theme modules can contain one or more color
16 themes. The module must define a package global variable named
17 %color_themes that contain color themes keyed by their names. Example:
18
19 package MyProject::ColorThemes::Default;
20
21 our %color_themes = (
22 no_color => {
23 v => 1.1,
24 summary => 'Special theme that means no color',
25 colors => {
26 },
27 no_color => 1,
28 },
29
30 default => {
31 v => 1.1,
32 summary => 'Default color theme',
33 colors => {
34 },
35 },
36 );
37
38ATTRIBUTES
39 color_theme => HASH
40 Get/set color theme.
41
42 color_theme_args => HASH
43 Get/set arguments for color theme. This can be
44
45 color_theme_module_prefix => STR (default: CLASS + "::ColorTheme::")
46 Each project should have its own class prefix. For example,
47 Text::ANSITable has its color themes in "Text::ANSITable::ColorTheme::"
48 namespace, Data::Dump::Color has them in
49 "Data::Dump::Color::ColorTheme::" and so on.
50
51METHODS
52 $cl->list_color_themes($detail) => array
53 Will search packages under "color_theme_module_prefix" for color theme
54 modules, then list all color themes for each module. If, for example,
55 the color theme modules found are "MyProject::ColorTheme::Default" and
56 "MyProject::ColorTheme::Extras", will return something like:
57
58 ['Default::theme1', 'Default::theme2', 'Extras::extra3', 'Extras::extra4']
59
60 $cl->get_color_theme($name) => hash
61 Get color theme hash data structure by name. Note that name must be
62 prefixed by color theme module name (minus the
63 "color_theme_module_prefix").
64
65 $cl->get_theme_color($item_name) => str
66 Get an item's color value from the current color theme (will get from
67 the color theme's "colors" hash, then the $item_name key from that
68 hash). If color value is a coderef, it will be
69
70 $cl->get_theme_color_as_rgb($item_name, \%args) => str|hash
71 Like "get_theme_color", but if the resulting color value is a coderef,
72 will call that coderef, passing %args to it and returning the value.
73
74HOMEPAGE
75 Please visit the project's homepage at
76 <https://metacpan.org/release/Color-Theme-Role>.
77
78SOURCE
79 Source repository is at
80 <https://github.com/perlancar/perl-Color-Theme-Role>.
81
82BUGS
83 Please report any bugs or feature requests on the bugtracker website
84 <https://rt.cpan.org/Public/Dist/Display.html?Name=Color-Theme-Role>
85
86 When submitting a bug or request, please include a test-file or a patch
87 to an existing test-file that illustrates the bug or desired feature.
88
89SEE ALSO
90 Color::Theme
91
92AUTHOR
93 perlancar <perlancar@cpan.org>
94
95COPYRIGHT AND LICENSE
96 This software is copyright (c) 2018 by perlancar@cpan.org.
97
98 This is free software; you can redistribute it and/or modify it under
99 the same terms as the Perl 5 programming language system itself.
100
101