@@ -15,67 +15,106 @@ public struct ListMarkerConfiguration {
15
15
extension BlockStyle where Configuration == ListMarkerConfiguration {
16
16
/// A list marker style that uses decimal numbers beginning with 1.
17
17
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 {
18
66
BlockStyle { configuration in
19
67
Text ( " \( configuration. itemNumber) . " )
20
68
. monospacedDigit ( )
21
- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
69
+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
22
70
}
23
71
}
24
72
25
73
/// 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 {
27
75
BlockStyle { configuration in
28
76
Text ( configuration. itemNumber. roman + " . " )
29
- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
77
+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
30
78
}
31
79
}
32
80
33
81
/// 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 {
35
83
BlockStyle { configuration in
36
84
Text ( configuration. itemNumber. roman. lowercased ( ) + " . " )
37
- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
85
+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
38
86
}
39
87
}
40
88
41
89
/// 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 {
43
91
BlockStyle { _ in
44
92
Text ( " - " )
45
- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
93
+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
46
94
}
47
95
}
48
96
49
97
/// 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 {
51
99
BlockStyle { _ in
52
100
ListBullet . disc
53
- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
101
+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
54
102
}
55
103
}
56
104
57
105
/// 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 {
59
107
BlockStyle { _ in
60
108
ListBullet . circle
61
- . relativeFrame ( minWidth: . em ( 1.5 ) , alignment: . trailing )
109
+ . relativeFrame ( minWidth: minWidth , alignment: alignment )
62
110
}
63
111
}
64
112
65
113
/// 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 {
67
115
BlockStyle { _ in
68
116
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)
79
118
}
80
119
}
81
120
}
0 commit comments