@@ -15,67 +15,106 @@ public struct ListMarkerConfiguration {
1515extension BlockStyle where Configuration == ListMarkerConfiguration {
1616 /// A list marker style that uses decimal numbers beginning with 1.
1717 public static var decimal : Self {
18+ decimal ( minWidth: . em( 1.5 ) , alignment: . trailing)
19+ }
20+
21+ /// A list marker style that uses uppercase roman numerals beginning with `I`.
22+ public static var upperRoman : Self {
23+ upperRoman ( minWidth: . em( 1.5 ) , alignment: . trailing)
24+ }
25+
26+ /// A list marker style that uses lowercase roman numerals beginning with `i`.
27+ public static var lowerRoman : Self {
28+ lowerRoman ( minWidth: . em( 1.5 ) , alignment: . trailing)
29+ }
30+
31+ /// A list marker style that uses a dash.
32+ public static var dash : Self {
33+ dash ( minWidth: . em( 1.5 ) , alignment: . trailing)
34+ }
35+
36+ /// A list marker style that uses a filled circle.
37+ public static var disc : Self {
38+ disc ( minWidth: . em( 1.5 ) , alignment: . trailing)
39+ }
40+
41+ /// A list marker style that uses a hollow circle.
42+ public static var circle : Self {
43+ circle ( minWidth: . em( 1.5 ) , alignment: . trailing)
44+ }
45+
46+ /// A list marker style that uses a filled square.
47+ public static var square : Self {
48+ square ( minWidth: . em( 1.5 ) , alignment: . trailing)
49+ }
50+
51+ /// A list marker style that alternates between disc, circle, and square, depending on the list level.
52+ public static var discCircleSquare : Self {
53+ BlockStyle { configuration in
54+ let styles : [ Self ] = [ . disc, . circle, . square]
55+ styles [ min ( configuration. listLevel, styles. count) - 1 ]
56+ . makeBody ( configuration: configuration)
57+ }
58+ }
59+ }
60+
61+ // MARK: Dynamic
62+
63+ extension BlockStyle where Configuration == ListMarkerConfiguration {
64+ /// A list marker style that uses decimal numbers beginning with 1.
65+ public static func decimal( minWidth: RelativeSize , alignment: Alignment = . center) -> Self {
1866 BlockStyle { configuration in
1967 Text ( " \( configuration. itemNumber) . " )
2068 . monospacedDigit ( )
21- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
69+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
2270 }
2371 }
2472
2573 /// A list marker style that uses uppercase roman numerals beginning with `I`.
26- public static var upperRoman : Self {
74+ public static func upperRoman( minWidth : RelativeSize , alignment : Alignment = . center ) -> Self {
2775 BlockStyle { configuration in
2876 Text ( configuration. itemNumber. roman + " . " )
29- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
77+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
3078 }
3179 }
3280
3381 /// A list marker style that uses lowercase roman numerals beginning with `i`.
34- public static var lowerRoman : Self {
82+ public static func lowerRoman( minWidth : RelativeSize , alignment : Alignment = . center ) -> Self {
3583 BlockStyle { configuration in
3684 Text ( configuration. itemNumber. roman. lowercased ( ) + " . " )
37- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
85+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
3886 }
3987 }
4088
4189 /// A list marker style that uses a dash.
42- public static var dash : Self {
90+ public static func dash( minWidth : RelativeSize , alignment : Alignment = . center ) -> Self {
4391 BlockStyle { _ in
4492 Text ( " - " )
45- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
93+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
4694 }
4795 }
4896
4997 /// A list marker style that uses a filled circle.
50- public static var disc : Self {
98+ public static func disc( minWidth : RelativeSize , alignment : Alignment = . center ) -> Self {
5199 BlockStyle { _ in
52100 ListBullet . disc
53- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
101+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
54102 }
55103 }
56104
57105 /// A list marker style that uses a hollow circle.
58- public static var circle : Self {
106+ public static func circle( minWidth : RelativeSize , alignment : Alignment = . center ) -> Self {
59107 BlockStyle { _ in
60108 ListBullet . circle
61- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
109+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
62110 }
63111 }
64112
65113 /// A list marker style that uses a filled square.
66- public static var square : Self {
114+ public static func square( minWidth : RelativeSize , alignment : Alignment = . center ) -> Self {
67115 BlockStyle { _ in
68116 ListBullet . square
69- . relativeFrame ( minWidth: . em( 1.5 ) , alignment: . trailing)
70- }
71- }
72-
73- /// A list marker style that alternates between disc, circle, and square, depending on the list level.
74- public static var discCircleSquare : Self {
75- BlockStyle { configuration in
76- let styles : [ Self ] = [ . disc, . circle, . square]
77- styles [ min ( configuration. listLevel, styles. count) - 1 ]
78- . makeBody ( configuration: configuration)
117+ . relativeFrame ( minWidth: minWidth, alignment: alignment)
79118 }
80119 }
81120}
0 commit comments