File tree Expand file tree Collapse file tree 7 files changed +51
-0
lines changed Expand file tree Collapse file tree 7 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 55// Created by Tibor Bodecs on 2022. 01. 24..
66//
77
8+ /// represents a CSS media query
89public struct MediaQuery {
910
11+ /// device orientation
1012 public enum Orientation : String {
13+ /// portrait orientation
1114 case portrait
15+ /// landscape orientation
1216 case landscape
1317 }
1418
19+ /// device color scheme
1520 public enum ColorScheme : String {
21+ /// light mode
1622 case light
23+ /// dark mode
1724 case dark
1825 }
1926
27+ /// raw representation of the media query
2028 var value : String
2129
2230}
2331
2432public extension MediaQuery {
2533
34+ /// screen
2635 static let screen = MediaQuery ( value: " screen " )
2736
37+ /// device width in pixels
2838 static func deviceWidth( px: Int ) -> MediaQuery {
2939 . init( value: " (device-width: \( px) px) " )
3040 }
3141
42+ /// device height in pixels
3243 static func deviceHeight( px: Int ) -> MediaQuery {
3344 . init( value: " (device-height: \( px) px) " )
3445 }
3546
47+ /// device pixel ratio with webkit prefix
3648 static func webkitDevicePixelRatio( _ value: Int ) -> MediaQuery {
3749 . init( value: " (-webkit-device-pixel-ratio: \( value) ) " )
3850 }
3951
52+ /// device orientation
4053 static func orientation( _ value: Orientation ) -> MediaQuery {
4154 . init( value: " (orientation: \( value. rawValue) ) " )
4255 }
4356
57+ /// preferred color scheme
4458 static func prefersColorScheme( _ value: ColorScheme ) -> MediaQuery {
4559 . init( value: " (prefers-color-scheme: \( value. rawValue) ) " )
4660 }
Original file line number Diff line number Diff line change @@ -77,10 +77,16 @@ public extension A {
7777 attribute ( " media " , value)
7878 }
7979
80+ /// Specifies what media/device the linked document is optimized for
81+ ///
82+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
8083 func media( _ queries: MediaQuery ... ) -> Self {
8184 return media ( queries)
8285 }
8386
87+ /// Specifies what media/device the linked document is optimized for
88+ ///
89+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
8490 func media( _ queries: [ MediaQuery ] ) -> Self {
8591 return media ( queries. map ( \. value) . joined ( separator: " and " ) )
8692 }
Original file line number Diff line number Diff line change @@ -87,10 +87,16 @@ public extension Area {
8787 attribute ( " media " , value)
8888 }
8989
90+ /// Specifies what media/device the linked document is optimized for
91+ ///
92+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
9093 func media( _ queries: MediaQuery ... ) -> Self {
9194 return media ( queries)
9295 }
9396
97+ /// Specifies what media/device the linked document is optimized for
98+ ///
99+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
94100 func media( _ queries: [ MediaQuery ] ) -> Self {
95101 return media ( queries. map ( \. value) . joined ( separator: " and " ) )
96102 }
Original file line number Diff line number Diff line change @@ -93,10 +93,16 @@ public extension Link {
9393 attribute ( " media " , value)
9494 }
9595
96+ /// Specifies what media/device the linked document is optimized for
97+ ///
98+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
9699 func media( _ queries: MediaQuery ... ) -> Self {
97100 return media ( queries)
98101 }
99102
103+ /// Specifies what media/device the linked document is optimized for
104+ ///
105+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
100106 func media( _ queries: [ MediaQuery ] ) -> Self {
101107 return media ( queries. map ( \. value) . joined ( separator: " and " ) )
102108 }
Original file line number Diff line number Diff line change @@ -83,14 +83,21 @@ public extension Meta {
8383 name ( value. rawValue)
8484 }
8585
86+ /// Specifies what media/device the linked document is optimized for
8687 func media( _ value: String ) -> Self {
8788 attribute ( " media " , value)
8889 }
8990
91+ /// Specifies what media/device the linked document is optimized for
92+ ///
93+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
9094 func media( _ queries: MediaQuery ... ) -> Self {
9195 return media ( queries)
9296 }
9397
98+ /// Specifies what media/device the linked document is optimized for
99+ ///
100+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
94101 func media( _ queries: [ MediaQuery ] ) -> Self {
95102 return media ( queries. map ( \. value) . joined ( separator: " and " ) )
96103 }
Original file line number Diff line number Diff line change @@ -24,10 +24,16 @@ public extension Source {
2424 attribute ( " media " , value)
2525 }
2626
27+ /// Specifies what media/device the linked document is optimized for
28+ ///
29+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
2730 func media( _ queries: MediaQuery ... ) -> Self {
2831 return media ( queries)
2932 }
3033
34+ /// Specifies what media/device the linked document is optimized for
35+ ///
36+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
3137 func media( _ queries: [ MediaQuery ] ) -> Self {
3238 return media ( queries. map ( \. value) . joined ( separator: " and " ) )
3339 }
Original file line number Diff line number Diff line change @@ -23,10 +23,16 @@ public extension Style {
2323 attribute ( " media " , value)
2424 }
2525
26+ /// Specifies what media/device the linked document is optimized for
27+ ///
28+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
2629 func media( _ queries: MediaQuery ... ) -> Self {
2730 return media ( queries)
2831 }
2932
33+ /// Specifies what media/device the linked document is optimized for
34+ ///
35+ /// If multiple queries were provided they're going to be concatenated with an `and` operand
3036 func media( _ queries: [ MediaQuery ] ) -> Self {
3137 return media ( queries. map ( \. value) . joined ( separator: " and " ) )
3238 }
You can’t perform that action at this time.
0 commit comments