diff --git a/packages/spark_css/CHANGELOG.md b/packages/spark_css/CHANGELOG.md index ec8a3f7..80a5209 100644 --- a/packages/spark_css/CHANGELOG.md +++ b/packages/spark_css/CHANGELOG.md @@ -25,6 +25,12 @@ - **Feat**: Added `CssTextOverflow` sealed class for `text-overflow` property with `.clip`, `.ellipsis` keywords, `.value()` for custom strings, plus `.variable()`, `.raw()`, and `.global()` escape hatches. - **Feat**: Added `CssAspectRatio` sealed class for `aspect-ratio` property with `.auto` keyword, `.ratio()`, `.number()`, plus `.variable()`, `.raw()`, and `.global()` escape hatches. - **Feat**: Added `CssPlaceItems` sealed class for `place-items` shorthand property with align and optional justify parameters, plus `.variable()`, `.raw()`, and `.global()` escape hatches. +- **Feat**: Added `CssPlaceContent` sealed class for `place-content` shorthand property with `CssAlignContent` and optional `CssJustifyContent` parameters, plus `.variable()`, `.raw()`, and `.global()` escape hatches. +- **Feat**: Added `CssPlaceSelf` sealed class for `place-self` shorthand property with `CssAlignSelf` and optional `CssJustifySelf` parameters, plus `.variable()`, `.raw()`, and `.global()` escape hatches. +- **Feat**: Added `CssJustifySelf` sealed class for `justify-self` property with `.auto`, `.normal`, `.stretch`, `.start`, `.end`, `.center`, `.left`, `.right`, `.baseline`, `.firstBaseline`, `.lastBaseline`, `.selfStart`, `.selfEnd` keywords, plus `.variable()`, `.raw()`, and `.global()` escape hatches. +- **Feat**: Added `CssIsolation` sealed class for `isolation` property with `.auto`, `.isolate` keywords, plus `.variable()`, `.raw()`, and `.global()` escape hatches. +- **Feat**: Added `CssMixBlendMode` sealed class for `mix-blend-mode` property with `.normal`, `.multiply`, `.screen`, `.overlay`, `.darken`, `.lighten`, `.colorDodge`, `.colorBurn`, `.hardLight`, `.softLight`, `.difference`, `.exclusion`, `.hue`, `.saturation`, `.color`, `.luminosity` keywords, plus `.variable()`, `.raw()`, and `.global()` escape hatches. +- **Feat**: Added `CssBackgroundBlendMode` sealed class for `background-blend-mode` property with `.normal`, `.multiply`, `.screen`, `.overlay`, `.darken`, `.lighten`, `.colorDodge`, `.colorBurn`, `.hardLight`, `.softLight`, `.difference`, `.exclusion`, `.hue`, `.saturation`, `.color`, `.luminosity` keywords, plus `.variable()`, `.raw()`, and `.global()` escape hatches. ### Changed diff --git a/packages/spark_css/lib/src/css_types/css_background_blend_mode.dart b/packages/spark_css/lib/src/css_types/css_background_blend_mode.dart new file mode 100644 index 0000000..763839f --- /dev/null +++ b/packages/spark_css/lib/src/css_types/css_background_blend_mode.dart @@ -0,0 +1,90 @@ +import 'css_value.dart'; + +/// CSS background-blend-mode property values. +sealed class CssBackgroundBlendMode implements CssValue { + const CssBackgroundBlendMode._(); + + static const CssBackgroundBlendMode normal = _CssBackgroundBlendModeKeyword( + 'normal', + ); + static const CssBackgroundBlendMode multiply = _CssBackgroundBlendModeKeyword( + 'multiply', + ); + static const CssBackgroundBlendMode screen = _CssBackgroundBlendModeKeyword( + 'screen', + ); + static const CssBackgroundBlendMode overlay = _CssBackgroundBlendModeKeyword( + 'overlay', + ); + static const CssBackgroundBlendMode darken = _CssBackgroundBlendModeKeyword( + 'darken', + ); + static const CssBackgroundBlendMode lighten = _CssBackgroundBlendModeKeyword( + 'lighten', + ); + static const CssBackgroundBlendMode colorDodge = + _CssBackgroundBlendModeKeyword('color-dodge'); + static const CssBackgroundBlendMode colorBurn = + _CssBackgroundBlendModeKeyword('color-burn'); + static const CssBackgroundBlendMode hardLight = + _CssBackgroundBlendModeKeyword('hard-light'); + static const CssBackgroundBlendMode softLight = + _CssBackgroundBlendModeKeyword('soft-light'); + static const CssBackgroundBlendMode difference = + _CssBackgroundBlendModeKeyword('difference'); + static const CssBackgroundBlendMode exclusion = + _CssBackgroundBlendModeKeyword('exclusion'); + static const CssBackgroundBlendMode hue = _CssBackgroundBlendModeKeyword( + 'hue', + ); + static const CssBackgroundBlendMode saturation = + _CssBackgroundBlendModeKeyword('saturation'); + static const CssBackgroundBlendMode color = _CssBackgroundBlendModeKeyword( + 'color', + ); + static const CssBackgroundBlendMode luminosity = + _CssBackgroundBlendModeKeyword('luminosity'); + + /// CSS variable reference. + factory CssBackgroundBlendMode.variable(String varName) = + _CssBackgroundBlendModeVariable; + + /// Raw CSS value escape hatch. + factory CssBackgroundBlendMode.raw(String value) = _CssBackgroundBlendModeRaw; + + /// Global keyword (inherit, initial, unset, revert). + factory CssBackgroundBlendMode.global(CssGlobal global) = + _CssBackgroundBlendModeGlobal; +} + +final class _CssBackgroundBlendModeKeyword extends CssBackgroundBlendMode { + final String keyword; + const _CssBackgroundBlendModeKeyword(this.keyword) : super._(); + + @override + String toCss() => keyword; +} + +final class _CssBackgroundBlendModeVariable extends CssBackgroundBlendMode { + final String varName; + const _CssBackgroundBlendModeVariable(this.varName) : super._(); + + @override + String toCss() => 'var(--$varName)'; +} + +final class _CssBackgroundBlendModeRaw extends CssBackgroundBlendMode { + final String value; + const _CssBackgroundBlendModeRaw(this.value) : super._(); + + @override + String toCss() => value; +} + +final class _CssBackgroundBlendModeGlobal extends CssBackgroundBlendMode { + final CssGlobal global; + const _CssBackgroundBlendModeGlobal(this.global) : super._(); + + @override + String toCss() => global.toCss(); +} diff --git a/packages/spark_css/lib/src/css_types/css_isolation.dart b/packages/spark_css/lib/src/css_types/css_isolation.dart new file mode 100644 index 0000000..1ef6ddd --- /dev/null +++ b/packages/spark_css/lib/src/css_types/css_isolation.dart @@ -0,0 +1,50 @@ +import 'css_value.dart'; + +/// CSS isolation property values. +sealed class CssIsolation implements CssValue { + const CssIsolation._(); + + static const CssIsolation auto = _CssIsolationKeyword('auto'); + static const CssIsolation isolate = _CssIsolationKeyword('isolate'); + + /// CSS variable reference. + factory CssIsolation.variable(String varName) = _CssIsolationVariable; + + /// Raw CSS value escape hatch. + factory CssIsolation.raw(String value) = _CssIsolationRaw; + + /// Global keyword (inherit, initial, unset, revert). + factory CssIsolation.global(CssGlobal global) = _CssIsolationGlobal; +} + +final class _CssIsolationKeyword extends CssIsolation { + final String keyword; + const _CssIsolationKeyword(this.keyword) : super._(); + + @override + String toCss() => keyword; +} + +final class _CssIsolationVariable extends CssIsolation { + final String varName; + const _CssIsolationVariable(this.varName) : super._(); + + @override + String toCss() => 'var(--$varName)'; +} + +final class _CssIsolationRaw extends CssIsolation { + final String value; + const _CssIsolationRaw(this.value) : super._(); + + @override + String toCss() => value; +} + +final class _CssIsolationGlobal extends CssIsolation { + final CssGlobal global; + const _CssIsolationGlobal(this.global) : super._(); + + @override + String toCss() => global.toCss(); +} diff --git a/packages/spark_css/lib/src/css_types/css_justify_self.dart b/packages/spark_css/lib/src/css_types/css_justify_self.dart new file mode 100644 index 0000000..c65e7f6 --- /dev/null +++ b/packages/spark_css/lib/src/css_types/css_justify_self.dart @@ -0,0 +1,65 @@ +import 'css_value.dart'; + +/// CSS justify-self property values. +sealed class CssJustifySelf implements CssValue { + const CssJustifySelf._(); + + static const CssJustifySelf auto = _CssJustifySelfKeyword('auto'); + static const CssJustifySelf normal = _CssJustifySelfKeyword('normal'); + static const CssJustifySelf stretch = _CssJustifySelfKeyword('stretch'); + static const CssJustifySelf start = _CssJustifySelfKeyword('start'); + static const CssJustifySelf end = _CssJustifySelfKeyword('end'); + static const CssJustifySelf center = _CssJustifySelfKeyword('center'); + static const CssJustifySelf left = _CssJustifySelfKeyword('left'); + static const CssJustifySelf right = _CssJustifySelfKeyword('right'); + static const CssJustifySelf baseline = _CssJustifySelfKeyword('baseline'); + static const CssJustifySelf firstBaseline = _CssJustifySelfKeyword( + 'first baseline', + ); + static const CssJustifySelf lastBaseline = _CssJustifySelfKeyword( + 'last baseline', + ); + static const CssJustifySelf selfStart = _CssJustifySelfKeyword('self-start'); + static const CssJustifySelf selfEnd = _CssJustifySelfKeyword('self-end'); + + /// CSS variable reference. + factory CssJustifySelf.variable(String varName) = _CssJustifySelfVariable; + + /// Raw CSS value escape hatch. + factory CssJustifySelf.raw(String value) = _CssJustifySelfRaw; + + /// Global keyword (inherit, initial, unset, revert). + factory CssJustifySelf.global(CssGlobal global) = _CssJustifySelfGlobal; +} + +final class _CssJustifySelfKeyword extends CssJustifySelf { + final String keyword; + const _CssJustifySelfKeyword(this.keyword) : super._(); + + @override + String toCss() => keyword; +} + +final class _CssJustifySelfVariable extends CssJustifySelf { + final String varName; + const _CssJustifySelfVariable(this.varName) : super._(); + + @override + String toCss() => 'var(--$varName)'; +} + +final class _CssJustifySelfRaw extends CssJustifySelf { + final String value; + const _CssJustifySelfRaw(this.value) : super._(); + + @override + String toCss() => value; +} + +final class _CssJustifySelfGlobal extends CssJustifySelf { + final CssGlobal global; + const _CssJustifySelfGlobal(this.global) : super._(); + + @override + String toCss() => global.toCss(); +} diff --git a/packages/spark_css/lib/src/css_types/css_mix_blend_mode.dart b/packages/spark_css/lib/src/css_types/css_mix_blend_mode.dart new file mode 100644 index 0000000..e3dce11 --- /dev/null +++ b/packages/spark_css/lib/src/css_types/css_mix_blend_mode.dart @@ -0,0 +1,78 @@ +import 'css_value.dart'; + +/// CSS mix-blend-mode property values. +sealed class CssMixBlendMode implements CssValue { + const CssMixBlendMode._(); + + static const CssMixBlendMode normal = _CssMixBlendModeKeyword('normal'); + static const CssMixBlendMode multiply = _CssMixBlendModeKeyword('multiply'); + static const CssMixBlendMode screen = _CssMixBlendModeKeyword('screen'); + static const CssMixBlendMode overlay = _CssMixBlendModeKeyword('overlay'); + static const CssMixBlendMode darken = _CssMixBlendModeKeyword('darken'); + static const CssMixBlendMode lighten = _CssMixBlendModeKeyword('lighten'); + static const CssMixBlendMode colorDodge = _CssMixBlendModeKeyword( + 'color-dodge', + ); + static const CssMixBlendMode colorBurn = _CssMixBlendModeKeyword( + 'color-burn', + ); + static const CssMixBlendMode hardLight = _CssMixBlendModeKeyword( + 'hard-light', + ); + static const CssMixBlendMode softLight = _CssMixBlendModeKeyword( + 'soft-light', + ); + static const CssMixBlendMode difference = _CssMixBlendModeKeyword( + 'difference', + ); + static const CssMixBlendMode exclusion = _CssMixBlendModeKeyword('exclusion'); + static const CssMixBlendMode hue = _CssMixBlendModeKeyword('hue'); + static const CssMixBlendMode saturation = _CssMixBlendModeKeyword( + 'saturation', + ); + static const CssMixBlendMode color = _CssMixBlendModeKeyword('color'); + static const CssMixBlendMode luminosity = _CssMixBlendModeKeyword( + 'luminosity', + ); + + /// CSS variable reference. + factory CssMixBlendMode.variable(String varName) = _CssMixBlendModeVariable; + + /// Raw CSS value escape hatch. + factory CssMixBlendMode.raw(String value) = _CssMixBlendModeRaw; + + /// Global keyword (inherit, initial, unset, revert). + factory CssMixBlendMode.global(CssGlobal global) = _CssMixBlendModeGlobal; +} + +final class _CssMixBlendModeKeyword extends CssMixBlendMode { + final String keyword; + const _CssMixBlendModeKeyword(this.keyword) : super._(); + + @override + String toCss() => keyword; +} + +final class _CssMixBlendModeVariable extends CssMixBlendMode { + final String varName; + const _CssMixBlendModeVariable(this.varName) : super._(); + + @override + String toCss() => 'var(--$varName)'; +} + +final class _CssMixBlendModeRaw extends CssMixBlendMode { + final String value; + const _CssMixBlendModeRaw(this.value) : super._(); + + @override + String toCss() => value; +} + +final class _CssMixBlendModeGlobal extends CssMixBlendMode { + final CssGlobal global; + const _CssMixBlendModeGlobal(this.global) : super._(); + + @override + String toCss() => global.toCss(); +} diff --git a/packages/spark_css/lib/src/css_types/css_place_content.dart b/packages/spark_css/lib/src/css_types/css_place_content.dart new file mode 100644 index 0000000..31a53f9 --- /dev/null +++ b/packages/spark_css/lib/src/css_types/css_place_content.dart @@ -0,0 +1,56 @@ +import 'css_flex.dart'; +import 'css_value.dart'; + +/// CSS place-content shorthand property values. +sealed class CssPlaceContent implements CssValue { + const CssPlaceContent._(); + + /// Shorthand with align and optional justify. + factory CssPlaceContent(CssAlignContent align, [CssJustifyContent? justify]) = + _CssPlaceContentShorthand; + + /// CSS variable reference. + factory CssPlaceContent.variable(String varName) = _CssPlaceContentVariable; + + /// Raw CSS value escape hatch. + factory CssPlaceContent.raw(String value) = _CssPlaceContentRaw; + + /// Global keyword (inherit, initial, unset, revert). + factory CssPlaceContent.global(CssGlobal global) = _CssPlaceContentGlobal; +} + +final class _CssPlaceContentShorthand extends CssPlaceContent { + final CssAlignContent align; + final CssJustifyContent? justify; + const _CssPlaceContentShorthand(this.align, [this.justify]) : super._(); + + @override + String toCss() { + if (justify == null) return align.toCss(); + return '${align.toCss()} ${justify!.toCss()}'; + } +} + +final class _CssPlaceContentVariable extends CssPlaceContent { + final String varName; + const _CssPlaceContentVariable(this.varName) : super._(); + + @override + String toCss() => 'var(--$varName)'; +} + +final class _CssPlaceContentRaw extends CssPlaceContent { + final String value; + const _CssPlaceContentRaw(this.value) : super._(); + + @override + String toCss() => value; +} + +final class _CssPlaceContentGlobal extends CssPlaceContent { + final CssGlobal global; + const _CssPlaceContentGlobal(this.global) : super._(); + + @override + String toCss() => global.toCss(); +} diff --git a/packages/spark_css/lib/src/css_types/css_place_self.dart b/packages/spark_css/lib/src/css_types/css_place_self.dart new file mode 100644 index 0000000..68d8944 --- /dev/null +++ b/packages/spark_css/lib/src/css_types/css_place_self.dart @@ -0,0 +1,57 @@ +import 'css_flex.dart'; +import 'css_justify_self.dart'; +import 'css_value.dart'; + +/// CSS place-self shorthand property values. +sealed class CssPlaceSelf implements CssValue { + const CssPlaceSelf._(); + + /// Shorthand with align and optional justify. + factory CssPlaceSelf(CssAlignSelf align, [CssJustifySelf? justify]) = + _CssPlaceSelfShorthand; + + /// CSS variable reference. + factory CssPlaceSelf.variable(String varName) = _CssPlaceSelfVariable; + + /// Raw CSS value escape hatch. + factory CssPlaceSelf.raw(String value) = _CssPlaceSelfRaw; + + /// Global keyword (inherit, initial, unset, revert). + factory CssPlaceSelf.global(CssGlobal global) = _CssPlaceSelfGlobal; +} + +final class _CssPlaceSelfShorthand extends CssPlaceSelf { + final CssAlignSelf align; + final CssJustifySelf? justify; + const _CssPlaceSelfShorthand(this.align, [this.justify]) : super._(); + + @override + String toCss() { + if (justify == null) return align.toCss(); + return '${align.toCss()} ${justify!.toCss()}'; + } +} + +final class _CssPlaceSelfVariable extends CssPlaceSelf { + final String varName; + const _CssPlaceSelfVariable(this.varName) : super._(); + + @override + String toCss() => 'var(--$varName)'; +} + +final class _CssPlaceSelfRaw extends CssPlaceSelf { + final String value; + const _CssPlaceSelfRaw(this.value) : super._(); + + @override + String toCss() => value; +} + +final class _CssPlaceSelfGlobal extends CssPlaceSelf { + final CssGlobal global; + const _CssPlaceSelfGlobal(this.global) : super._(); + + @override + String toCss() => global.toCss(); +} diff --git a/packages/spark_css/lib/src/css_types/css_types.dart b/packages/spark_css/lib/src/css_types/css_types.dart index 0f51541..97f20af 100644 --- a/packages/spark_css/lib/src/css_types/css_types.dart +++ b/packages/spark_css/lib/src/css_types/css_types.dart @@ -6,6 +6,7 @@ export 'css_angle.dart'; export 'css_aspect_ratio.dart'; export 'css_background.dart'; export 'css_background_attachment.dart'; +export 'css_background_blend_mode.dart'; export 'css_background_clip.dart'; export 'css_background_image.dart'; export 'css_background_origin.dart'; @@ -27,14 +28,19 @@ export 'css_flex_shorthand.dart'; export 'css_font.dart'; export 'css_gradient_direction.dart'; export 'css_grid_template_columns.dart'; +export 'css_isolation.dart'; export 'css_justify_items.dart'; +export 'css_justify_self.dart'; export 'css_length.dart'; export 'css_list_style.dart'; +export 'css_mix_blend_mode.dart'; export 'css_number.dart'; export 'css_object_fit.dart'; export 'css_outline.dart'; export 'css_overflow.dart'; +export 'css_place_content.dart'; export 'css_place_items.dart'; +export 'css_place_self.dart'; export 'css_pointer_events.dart'; export 'css_position.dart'; export 'css_radial_shape.dart'; diff --git a/packages/spark_css/lib/src/style.dart b/packages/spark_css/lib/src/style.dart index 0b0202a..e5e4085 100644 --- a/packages/spark_css/lib/src/style.dart +++ b/packages/spark_css/lib/src/style.dart @@ -273,6 +273,8 @@ class Style implements CssStyle { CssLength? gap, CssFlexShorthand? flex, CssPlaceItems? placeItems, + CssPlaceContent? placeContent, + CssPlaceSelf? placeSelf, // Typography CssLength? fontSize, CssFontWeight? fontWeight, @@ -314,6 +316,8 @@ class Style implements CssStyle { CssPointerEvents? pointerEvents, CssResize? resize, CssScrollBehavior? scrollBehavior, + CssIsolation? isolation, + CssMixBlendMode? mixBlendMode, CssFilter? filter, CssFilter? backdropFilter, // Backgrounds @@ -324,6 +328,7 @@ class Style implements CssStyle { CssBackgroundClip? backgroundClip, CssBackgroundOrigin? backgroundOrigin, CssBackgroundAttachment? backgroundAttachment, + CssBackgroundBlendMode? backgroundBlendMode, // Effects CssAnimation? animation, CssTransition? transition, @@ -336,6 +341,7 @@ class Style implements CssStyle { CssGridTemplateColumns? gridTemplateColumns, // Alignment CssJustifyItems? justifyItems, + CssJustifySelf? justifySelf, // Lists CssListStyle? listStyle, Stylesheet? css, @@ -406,6 +412,10 @@ class Style implements CssStyle { if (gap != null) _properties['gap'] = gap.toCss(); if (flex != null) _properties['flex'] = flex.toCss(); if (placeItems != null) _properties['place-items'] = placeItems.toCss(); + if (placeContent != null) { + _properties['place-content'] = placeContent.toCss(); + } + if (placeSelf != null) _properties['place-self'] = placeSelf.toCss(); // Typography if (fontSize != null) _properties['font-size'] = fontSize.toCss(); @@ -478,6 +488,10 @@ class Style implements CssStyle { if (scrollBehavior != null) { _properties['scroll-behavior'] = scrollBehavior.toCss(); } + if (isolation != null) _properties['isolation'] = isolation.toCss(); + if (mixBlendMode != null) { + _properties['mix-blend-mode'] = mixBlendMode.toCss(); + } if (filter != null) _properties['filter'] = filter.toCss(); if (backdropFilter != null) { _properties['backdrop-filter'] = backdropFilter.toCss(); @@ -505,6 +519,9 @@ class Style implements CssStyle { if (backgroundAttachment != null) { _properties['background-attachment'] = backgroundAttachment.toCss(); } + if (backgroundBlendMode != null) { + _properties['background-blend-mode'] = backgroundBlendMode.toCss(); + } // Effects if (animation != null) _properties['animation'] = animation.toCss(); @@ -526,6 +543,9 @@ class Style implements CssStyle { if (justifyItems != null) { _properties['justify-items'] = justifyItems.toCss(); } + if (justifySelf != null) { + _properties['justify-self'] = justifySelf.toCss(); + } // Lists if (listStyle != null) _properties['list-style'] = listStyle.toCss(); diff --git a/packages/spark_css/test/css_background_blend_mode_test.dart b/packages/spark_css/test/css_background_blend_mode_test.dart new file mode 100644 index 0000000..b3e69d8 --- /dev/null +++ b/packages/spark_css/test/css_background_blend_mode_test.dart @@ -0,0 +1,66 @@ +import 'package:spark_css/spark_css.dart'; +import 'package:test/test.dart'; + +void main() { + group('CssBackgroundBlendMode', () { + test('keywords output correct CSS', () { + expect(CssBackgroundBlendMode.normal.toCss(), equals('normal')); + expect(CssBackgroundBlendMode.multiply.toCss(), equals('multiply')); + expect(CssBackgroundBlendMode.screen.toCss(), equals('screen')); + expect(CssBackgroundBlendMode.overlay.toCss(), equals('overlay')); + expect(CssBackgroundBlendMode.darken.toCss(), equals('darken')); + expect(CssBackgroundBlendMode.lighten.toCss(), equals('lighten')); + expect(CssBackgroundBlendMode.colorDodge.toCss(), equals('color-dodge')); + expect(CssBackgroundBlendMode.colorBurn.toCss(), equals('color-burn')); + expect(CssBackgroundBlendMode.hardLight.toCss(), equals('hard-light')); + expect(CssBackgroundBlendMode.softLight.toCss(), equals('soft-light')); + expect(CssBackgroundBlendMode.difference.toCss(), equals('difference')); + expect(CssBackgroundBlendMode.exclusion.toCss(), equals('exclusion')); + expect(CssBackgroundBlendMode.hue.toCss(), equals('hue')); + expect(CssBackgroundBlendMode.saturation.toCss(), equals('saturation')); + expect(CssBackgroundBlendMode.color.toCss(), equals('color')); + expect(CssBackgroundBlendMode.luminosity.toCss(), equals('luminosity')); + }); + + test('variable outputs correct CSS', () { + expect( + CssBackgroundBlendMode.variable('bbm').toCss(), + equals('var(--bbm)'), + ); + }); + + test('raw outputs value as-is', () { + expect(CssBackgroundBlendMode.raw('screen').toCss(), equals('screen')); + }); + + test('global outputs correct CSS', () { + expect( + CssBackgroundBlendMode.global(CssGlobal.inherit).toCss(), + equals('inherit'), + ); + expect( + CssBackgroundBlendMode.global(CssGlobal.initial).toCss(), + equals('initial'), + ); + expect( + CssBackgroundBlendMode.global(CssGlobal.unset).toCss(), + equals('unset'), + ); + expect( + CssBackgroundBlendMode.global(CssGlobal.revert).toCss(), + equals('revert'), + ); + expect( + CssBackgroundBlendMode.global(CssGlobal.revertLayer).toCss(), + equals('revert-layer'), + ); + }); + + test('Style.typed integration', () { + final style = Style.typed( + backgroundBlendMode: CssBackgroundBlendMode.screen, + ); + expect(style.toCss(), contains('background-blend-mode: screen;')); + }); + }); +} diff --git a/packages/spark_css/test/css_isolation_test.dart b/packages/spark_css/test/css_isolation_test.dart new file mode 100644 index 0000000..621e9db --- /dev/null +++ b/packages/spark_css/test/css_isolation_test.dart @@ -0,0 +1,35 @@ +import 'package:spark_css/spark_css.dart'; +import 'package:test/test.dart'; + +void main() { + group('CssIsolation', () { + test('keywords output correct CSS', () { + expect(CssIsolation.auto.toCss(), equals('auto')); + expect(CssIsolation.isolate.toCss(), equals('isolate')); + }); + + test('variable outputs correct CSS', () { + expect(CssIsolation.variable('iso').toCss(), equals('var(--iso)')); + }); + + test('raw outputs value as-is', () { + expect(CssIsolation.raw('isolate').toCss(), equals('isolate')); + }); + + test('global outputs correct CSS', () { + expect(CssIsolation.global(CssGlobal.inherit).toCss(), equals('inherit')); + expect(CssIsolation.global(CssGlobal.initial).toCss(), equals('initial')); + expect(CssIsolation.global(CssGlobal.unset).toCss(), equals('unset')); + expect(CssIsolation.global(CssGlobal.revert).toCss(), equals('revert')); + expect( + CssIsolation.global(CssGlobal.revertLayer).toCss(), + equals('revert-layer'), + ); + }); + + test('Style.typed integration', () { + final style = Style.typed(isolation: CssIsolation.isolate); + expect(style.toCss(), contains('isolation: isolate;')); + }); + }); +} diff --git a/packages/spark_css/test/css_justify_self_test.dart b/packages/spark_css/test/css_justify_self_test.dart new file mode 100644 index 0000000..6700a44 --- /dev/null +++ b/packages/spark_css/test/css_justify_self_test.dart @@ -0,0 +1,52 @@ +import 'package:spark_css/spark_css.dart'; +import 'package:test/test.dart'; + +void main() { + group('CssJustifySelf', () { + test('keywords output correct CSS', () { + expect(CssJustifySelf.auto.toCss(), equals('auto')); + expect(CssJustifySelf.normal.toCss(), equals('normal')); + expect(CssJustifySelf.stretch.toCss(), equals('stretch')); + expect(CssJustifySelf.start.toCss(), equals('start')); + expect(CssJustifySelf.end.toCss(), equals('end')); + expect(CssJustifySelf.center.toCss(), equals('center')); + expect(CssJustifySelf.left.toCss(), equals('left')); + expect(CssJustifySelf.right.toCss(), equals('right')); + expect(CssJustifySelf.baseline.toCss(), equals('baseline')); + expect(CssJustifySelf.firstBaseline.toCss(), equals('first baseline')); + expect(CssJustifySelf.lastBaseline.toCss(), equals('last baseline')); + expect(CssJustifySelf.selfStart.toCss(), equals('self-start')); + expect(CssJustifySelf.selfEnd.toCss(), equals('self-end')); + }); + + test('variable outputs correct CSS', () { + expect(CssJustifySelf.variable('js').toCss(), equals('var(--js)')); + }); + + test('raw outputs value as-is', () { + expect(CssJustifySelf.raw('center').toCss(), equals('center')); + }); + + test('global outputs correct CSS', () { + expect( + CssJustifySelf.global(CssGlobal.inherit).toCss(), + equals('inherit'), + ); + expect( + CssJustifySelf.global(CssGlobal.initial).toCss(), + equals('initial'), + ); + expect(CssJustifySelf.global(CssGlobal.unset).toCss(), equals('unset')); + expect(CssJustifySelf.global(CssGlobal.revert).toCss(), equals('revert')); + expect( + CssJustifySelf.global(CssGlobal.revertLayer).toCss(), + equals('revert-layer'), + ); + }); + + test('Style.typed integration', () { + final style = Style.typed(justifySelf: CssJustifySelf.center); + expect(style.toCss(), contains('justify-self: center;')); + }); + }); +} diff --git a/packages/spark_css/test/css_mix_blend_mode_test.dart b/packages/spark_css/test/css_mix_blend_mode_test.dart new file mode 100644 index 0000000..eb6d1a6 --- /dev/null +++ b/packages/spark_css/test/css_mix_blend_mode_test.dart @@ -0,0 +1,58 @@ +import 'package:spark_css/spark_css.dart'; +import 'package:test/test.dart'; + +void main() { + group('CssMixBlendMode', () { + test('keywords output correct CSS', () { + expect(CssMixBlendMode.normal.toCss(), equals('normal')); + expect(CssMixBlendMode.multiply.toCss(), equals('multiply')); + expect(CssMixBlendMode.screen.toCss(), equals('screen')); + expect(CssMixBlendMode.overlay.toCss(), equals('overlay')); + expect(CssMixBlendMode.darken.toCss(), equals('darken')); + expect(CssMixBlendMode.lighten.toCss(), equals('lighten')); + expect(CssMixBlendMode.colorDodge.toCss(), equals('color-dodge')); + expect(CssMixBlendMode.colorBurn.toCss(), equals('color-burn')); + expect(CssMixBlendMode.hardLight.toCss(), equals('hard-light')); + expect(CssMixBlendMode.softLight.toCss(), equals('soft-light')); + expect(CssMixBlendMode.difference.toCss(), equals('difference')); + expect(CssMixBlendMode.exclusion.toCss(), equals('exclusion')); + expect(CssMixBlendMode.hue.toCss(), equals('hue')); + expect(CssMixBlendMode.saturation.toCss(), equals('saturation')); + expect(CssMixBlendMode.color.toCss(), equals('color')); + expect(CssMixBlendMode.luminosity.toCss(), equals('luminosity')); + }); + + test('variable outputs correct CSS', () { + expect(CssMixBlendMode.variable('bm').toCss(), equals('var(--bm)')); + }); + + test('raw outputs value as-is', () { + expect(CssMixBlendMode.raw('multiply').toCss(), equals('multiply')); + }); + + test('global outputs correct CSS', () { + expect( + CssMixBlendMode.global(CssGlobal.inherit).toCss(), + equals('inherit'), + ); + expect( + CssMixBlendMode.global(CssGlobal.initial).toCss(), + equals('initial'), + ); + expect(CssMixBlendMode.global(CssGlobal.unset).toCss(), equals('unset')); + expect( + CssMixBlendMode.global(CssGlobal.revert).toCss(), + equals('revert'), + ); + expect( + CssMixBlendMode.global(CssGlobal.revertLayer).toCss(), + equals('revert-layer'), + ); + }); + + test('Style.typed integration', () { + final style = Style.typed(mixBlendMode: CssMixBlendMode.multiply); + expect(style.toCss(), contains('mix-blend-mode: multiply;')); + }); + }); +} diff --git a/packages/spark_css/test/css_place_content_test.dart b/packages/spark_css/test/css_place_content_test.dart new file mode 100644 index 0000000..9b596e0 --- /dev/null +++ b/packages/spark_css/test/css_place_content_test.dart @@ -0,0 +1,60 @@ +import 'package:spark_css/spark_css.dart'; +import 'package:test/test.dart'; + +void main() { + group('CssPlaceContent', () { + test('shorthand with align only outputs single value', () { + final pc = CssPlaceContent(CssAlignContent.center); + expect(pc.toCss(), equals('center')); + }); + + test('shorthand with align and justify outputs both values', () { + final pc = CssPlaceContent( + CssAlignContent.center, + CssJustifyContent.spaceBetween, + ); + expect(pc.toCss(), equals('center space-between')); + }); + + test('variable outputs correct CSS', () { + expect(CssPlaceContent.variable('pc').toCss(), equals('var(--pc)')); + }); + + test('raw outputs value as-is', () { + expect( + CssPlaceContent.raw('center start').toCss(), + equals('center start'), + ); + }); + + test('global outputs correct CSS', () { + expect( + CssPlaceContent.global(CssGlobal.inherit).toCss(), + equals('inherit'), + ); + expect( + CssPlaceContent.global(CssGlobal.initial).toCss(), + equals('initial'), + ); + expect(CssPlaceContent.global(CssGlobal.unset).toCss(), equals('unset')); + expect( + CssPlaceContent.global(CssGlobal.revert).toCss(), + equals('revert'), + ); + expect( + CssPlaceContent.global(CssGlobal.revertLayer).toCss(), + equals('revert-layer'), + ); + }); + + test('Style.typed integration', () { + final style = Style.typed( + placeContent: CssPlaceContent( + CssAlignContent.center, + CssJustifyContent.spaceEvenly, + ), + ); + expect(style.toCss(), contains('place-content: center space-evenly;')); + }); + }); +} diff --git a/packages/spark_css/test/css_place_self_test.dart b/packages/spark_css/test/css_place_self_test.dart new file mode 100644 index 0000000..7b2d789 --- /dev/null +++ b/packages/spark_css/test/css_place_self_test.dart @@ -0,0 +1,42 @@ +import 'package:spark_css/spark_css.dart'; +import 'package:test/test.dart'; + +void main() { + group('CssPlaceSelf', () { + test('shorthand with align only outputs single value', () { + final ps = CssPlaceSelf(CssAlignSelf.center); + expect(ps.toCss(), equals('center')); + }); + + test('shorthand with align and justify outputs both values', () { + final ps = CssPlaceSelf(CssAlignSelf.center, CssJustifySelf.start); + expect(ps.toCss(), equals('center start')); + }); + + test('variable outputs correct CSS', () { + expect(CssPlaceSelf.variable('ps').toCss(), equals('var(--ps)')); + }); + + test('raw outputs value as-is', () { + expect(CssPlaceSelf.raw('center start').toCss(), equals('center start')); + }); + + test('global outputs correct CSS', () { + expect(CssPlaceSelf.global(CssGlobal.inherit).toCss(), equals('inherit')); + expect(CssPlaceSelf.global(CssGlobal.initial).toCss(), equals('initial')); + expect(CssPlaceSelf.global(CssGlobal.unset).toCss(), equals('unset')); + expect(CssPlaceSelf.global(CssGlobal.revert).toCss(), equals('revert')); + expect( + CssPlaceSelf.global(CssGlobal.revertLayer).toCss(), + equals('revert-layer'), + ); + }); + + test('Style.typed integration', () { + final style = Style.typed( + placeSelf: CssPlaceSelf(CssAlignSelf.center, CssJustifySelf.end), + ); + expect(style.toCss(), contains('place-self: center end;')); + }); + }); +}