Skip to content

Commit 5542765

Browse files
committed
Move base-style() method to base-class
1 parent aaa7213 commit 5542765

File tree

6 files changed

+20
-30
lines changed

6 files changed

+20
-30
lines changed

docs/CSS/TagSet.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
/ [[CSS-TagSet]](https://css-raku.github.io/CSS-TagSet-raku)
33
/ [CSS::TagSet](https://css-raku.github.io/CSS-TagSet-raku/CSS/TagSet)
44

5+
6+
7+
interface role for tagsets
8+
59
Name
610
----
711

@@ -35,13 +39,13 @@ Default method to parse an inline style associated with the tag, typically the i
3539

3640
method tag-style(Str $tag, Str *%atts) returns CSS::Properties
3741

38-
Abstract method to compute a specific style, based on a tag-name and any additional tag attributes. This method must be implemented, by the class instance.
42+
Computes a specific style, based on a tag-name and any additional tag attributes. This method must be implemented, by the class instance.
3943

4044
By convention, this method vivifies a new empty [CSS::Properties](https://css-raku.github.io/CSS-Properties-raku/CSS/Properties) object, if the tag was previously unknown.
4145

4246
### method base-style
4347

44-
method tag-style(str $tag) returns CSS::Properties
48+
method base-style(str $tag) returns CSS::Properties
4549

46-
Abstract rule to
50+
Return the basic style for the tag.
4751

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ Classes
6565

6666
* [CSS::TagSet::Pango](https://css-raku.github.io/CSS-TagSet-raku/CSS/TagSet/Pango) - Implements Pango styling
6767

68-
* [CSS::TagSet::TaggedPDF](https://css-raku.github.io/CSS-TagSet-raku/CSS/TagSet/TaggedPDF) - (*UNDER CONSTRUCTION*) Implements Tagged PDF styling
68+
* [CSS::TagSet::TaggedPDF](https://css-raku.github.io/CSS-TagSet-raku/CSS/TagSet/TaggedPDF) - Implements Tagged PDF styling
6969

7070

lib/CSS/TagSet.rakumod

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ use CSS::Media;
55
use CSS::Properties;
66
use CSS::Stylesheet;
77
use CSS::Writer;
8+
has CSS::Properties %.props;
9+
has %.tags;
10+
has CSS::Module $.module = CSS::Module::CSS3.module;
11+
12+
method media { ... }
813

914
sub load-css-tagset($tag-css, CSS::Media :$media!, :%tags!, |c) is export(:load-css-tagset) {
1015
my CSS::Stylesheet $style-sheet;
@@ -58,7 +63,9 @@ method inline-style(Str $, Str :$style) {
5863
CSS::Properties.new(:$.module, :$style);
5964
}
6065

61-
method base-style(|c) { ... }
66+
method base-style(Str $tag) {
67+
%.props{$tag} //= CSS::Properties.new: :$.module, declarations => %.tags{$tag} // [];
68+
}
6269

6370
=begin pod
6471
@@ -94,14 +101,14 @@ from the `style` attribute.
94101
95102
method tag-style(Str $tag, Str *%atts) returns CSS::Properties
96103
97-
Abstract method to compute a specific style, based on a tag-name and any additional tag attributes. This method must be implemented, by the class instance.
104+
Computes a specific style, based on a tag-name and any additional tag attributes. This method must be implemented, by the class instance.
98105
99106
By convention, this method vivifies a new empty L<CSS::Properties> object, if the tag was previously unknown.
100107
101108
=head3 method base-style
102109
103-
method tag-style(str $tag) returns CSS::Properties
110+
method base-style(str $tag) returns CSS::Properties
104111
105-
Abstract rule to
112+
Return the basic style for the tag.
106113
107114
=end pod

lib/CSS/TagSet/Pango.rakumod

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ use CSS::Module::CSS3;
88
use CSS::Properties;
99
use CSS::Units;
1010

11-
has CSS::Module $.module = CSS::Module::CSS3.module;
12-
has CSS::Properties %!props;
1311
has CSS::Media $.media .= new: :type<screen>;
14-
has %!tags;
1512

1613
submethod TWEAK(IO() :$style-sheet) {
1714
my %CustomProps = %(
@@ -92,10 +89,6 @@ method load-stylesheet(IO() $_) {
9289

9390
method declarations { %!tags }
9491

95-
method base-style(Str $tag) {
96-
%!props{$tag} //= CSS::Properties.new(:$!module, declarations => %!tags{$tag}) // [];
97-
}
98-
9992
# mapping of Pango attributes to CSS properties
10093
has %!SpanProp = %(
10194
background => 'background-color',

lib/CSS/TagSet/TaggedPDF.rakumod

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ use CSS::Module::CSS3;
99
use CSS::Properties;
1010
use CSS::Units :pt;
1111

12-
has CSS::Module $.module = CSS::Module::CSS3.module;
1312
has CSS::Media $.media .= new: :type<print>;
14-
has CSS::Properties %!props;
15-
has %!tags;
1613

1714
submethod TWEAK(IO() :$style-sheet) {
1815
my %CustomProps = %(
@@ -37,10 +34,6 @@ method load-stylesheet(IO() $_) {
3734

3835
method declarations { %!tags }
3936

40-
method base-style(Str $tag) {
41-
%!props{$tag} //= CSS::Properties.new: :$!module, declarations => %!tags{$tag} // [];
42-
}
43-
4437
sub snake-case($s) {
4538
$s.split(/<?after .><?before <[A..Z]>>/)».lc.join: '-'
4639
}
@@ -90,7 +83,7 @@ method tag-style($tag, *%attrs --> CSS::Properties:D) {
9083
$css."$_"() = $value;
9184
}
9285
when HashMap {
93-
$css."{.key}"() = $_ with .value{$value};
86+
$css."{.key}"() = $_ with .value{$value};
9487
}
9588
when Code {
9689
with .($key, $value) -> $kv {

lib/CSS/TagSet/XHTML.rakumod

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ use CSS::Module::CSS3;
88
use CSS::Properties;
99
use URI;
1010

11-
has CSS::Properties %!props;
1211
has CSS::Media $.media .= new: :type<screen>;
1312
has SetHash %!link-pseudo;
14-
has CSS::Module $.module = CSS::Module::CSS3.module;
15-
has %!tags;
1613

1714
submethod TWEAK(IO() :$style-sheet) {
1815
my %CustomProps = %(
@@ -41,10 +38,6 @@ method load-stylesheet(IO() $_) {
4138

4239
method declarations { %!tags }
4340

44-
method base-style(Str $prop) {
45-
%!props{$prop} //= CSS::Properties.new(:$!module, declarations => %!tags{$prop} // []);
46-
}
47-
4841
# mapping of HTML attributes to CSS properties
4942
constant %AttrProp = %(
5043
align => '-xhtml-align',

0 commit comments

Comments
 (0)