move.gl 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/css/move.gl.css +2 -0
  4. package/css/move.gl.min.css +2 -0
  5. package/package.json +55 -0
  6. package/scss/classes/_animations.scss +576 -0
  7. package/scss/classes/_index.scss +0 -0
  8. package/scss/classes/_transforms.scss +124 -0
  9. package/scss/classes/keyboard.scss +18 -0
  10. package/scss/classes/screensaver.scss +15 -0
  11. package/scss/dev/_banner.scss +36 -0
  12. package/scss/dev/_debug.scss +18 -0
  13. package/scss/dev/_deprecation.scss +10 -0
  14. package/scss/dev/_index.scss +8 -0
  15. package/scss/dev/_modules.scss +24 -0
  16. package/scss/effects/_filter.scss +176 -0
  17. package/scss/effects/_index.scss +23 -0
  18. package/scss/effects/_opacity.scss +62 -0
  19. package/scss/effects/_shadow.scss +175 -0
  20. package/scss/functions/_index.scss +0 -0
  21. package/scss/functions/scenes/_bubble.scss +19 -0
  22. package/scss/functions/scenes/_index.scss +20 -0
  23. package/scss/index.scss +0 -0
  24. package/scss/keyframes/_beat.scss +26 -0
  25. package/scss/keyframes/_index.scss +0 -0
  26. package/scss/maps/_index.scss +0 -0
  27. package/scss/maps/_mouse.scss +96 -0
  28. package/scss/mixins/_accessibility.scss +70 -0
  29. package/scss/mixins/_boot.scss +51 -0
  30. package/scss/mixins/_hover.scss +51 -0
  31. package/scss/mixins/_index.scss +0 -0
  32. package/scss/mixins/_selection.scss +321 -0
  33. package/scss/mixins/_shape.scss +44 -0
  34. package/scss/mixins/_touch.scss +95 -0
  35. package/scss/mixins/animations/--hover.scss +107 -0
  36. package/scss/mixins/animations/_base.scss +337 -0
  37. package/scss/mixins/animations/_beat.scss +119 -0
  38. package/scss/mixins/animations/_blink.scss +151 -0
  39. package/scss/mixins/animations/_bounce.scss +192 -0
  40. package/scss/mixins/animations/_elastic.scss +65 -0
  41. package/scss/mixins/animations/_fade.scss +154 -0
  42. package/scss/mixins/animations/_flash.scss +177 -0
  43. package/scss/mixins/animations/_flip.scss +72 -0
  44. package/scss/mixins/animations/_float.scss +126 -0
  45. package/scss/mixins/animations/_glow.scss +179 -0
  46. package/scss/mixins/animations/_heartbeat.scss +175 -0
  47. package/scss/mixins/animations/_hinge.scss +119 -0
  48. package/scss/mixins/animations/_index.scss +37 -0
  49. package/scss/mixins/animations/_jello.scss +129 -0
  50. package/scss/mixins/animations/_jiggle.scss +163 -0
  51. package/scss/mixins/animations/_lightspeed.scss +130 -0
  52. package/scss/mixins/animations/_nod.scss +161 -0
  53. package/scss/mixins/animations/_pop.scss +150 -0
  54. package/scss/mixins/animations/_pulse.scss +213 -0
  55. package/scss/mixins/animations/_ripple.scss +169 -0
  56. package/scss/mixins/animations/_roll.scss +261 -0
  57. package/scss/mixins/animations/_rotate.scss +428 -0
  58. package/scss/mixins/animations/_rubber.scss +116 -0
  59. package/scss/mixins/animations/_scale.scss +113 -0
  60. package/scss/mixins/animations/_shake.scss +182 -0
  61. package/scss/mixins/animations/_slide.scss +294 -0
  62. package/scss/mixins/animations/_spin.scss +219 -0
  63. package/scss/mixins/animations/_sway.scss +167 -0
  64. package/scss/mixins/animations/_swing.scss +247 -0
  65. package/scss/mixins/animations/_tada.scss +233 -0
  66. package/scss/mixins/animations/_twist.scss +177 -0
  67. package/scss/mixins/animations/_wave.scss +166 -0
  68. package/scss/mixins/animations/_wobble.scss +254 -0
  69. package/scss/mixins/animations/_zoom.scss +166 -0
  70. package/scss/mixins/effects/_filter.scss +148 -0
  71. package/scss/mixins/effects/_index.scss +0 -0
  72. package/scss/mixins/effects/_shadow.scss +21 -0
  73. package/scss/mixins/loaders/_index.scss +0 -0
  74. package/scss/mixins/loaders/_progress.scss +174 -0
  75. package/scss/mixins/loaders/_spinner.scss +101 -0
  76. package/scss/mixins/loaders/circle_01.scss +22 -0
  77. package/scss/mixins/loaders/circle_02.scss +19 -0
  78. package/scss/mixins/loaders/circle_03.scss +29 -0
  79. package/scss/mixins/loaders/circle_inner_01.scss +33 -0
  80. package/scss/mixins/loaders/circle_inner_02.scss +33 -0
  81. package/scss/mixins/loaders/circle_inner_03.scss +34 -0
  82. package/scss/mixins/mouse/_cursor.scss +182 -0
  83. package/scss/mixins/mouse/_index.scss +0 -0
  84. package/scss/mixins/mouse/_pointer.scss +258 -0
  85. package/scss/mixins/scroll/_index.scss +0 -0
  86. package/scss/mixins/scroll/_scroll.scss +104 -0
  87. package/scss/mixins/scroll/_scrollbar.scss +249 -0
  88. package/scss/mixins/transforms/_flip.scss +76 -0
  89. package/scss/mixins/transforms/_index.scss +23 -0
  90. package/scss/mixins/transforms/_matrix.scss +1 -0
  91. package/scss/mixins/transforms/_perspective.scss +11 -0
  92. package/scss/mixins/transforms/_rotate.scss +101 -0
  93. package/scss/mixins/transforms/_scale.scss +11 -0
  94. package/scss/mixins/transforms/_skew.scss +13 -0
  95. package/scss/mixins/transforms/_translate.scss +13 -0
  96. package/scss/mixins/transitions/_index.scss +0 -0
  97. package/scss/mixins/transitions/_transition.scss +13 -0
  98. package/scss/variables/_animation.scss +91 -0
  99. package/scss/variables/_index.scss +0 -0
  100. package/ts/ARContent.ts +27 -0
  101. package/ts/ARInteraction.ts +34 -0
  102. package/ts/AdaptiveUI.ts +25 -0
  103. package/ts/ContentStreaming.ts +20 -0
  104. package/ts/Draggable.ts +71 -0
  105. package/ts/DynamicEnvironment.ts +60 -0
  106. package/ts/Gesture.ts +168 -0
  107. package/ts/ImmersiveAudio.ts +40 -0
  108. package/ts/InteractiveCanvas.ts +177 -0
  109. package/ts/InteractiveVideo.ts +29 -0
  110. package/ts/Keyboard.ts +162 -0
  111. package/ts/RealTimeCollaboration.ts +25 -0
  112. package/ts/Screensaver.ts +140 -0
  113. package/ts/SpatialNavigation.ts +38 -0
  114. package/ts/UserProfile.ts +27 -0
  115. package/ts/VRExperience.ts +58 -0
  116. package/ts/VideoOverlay.ts +116 -0
  117. package/ts/index.ts +0 -0
File without changes
@@ -0,0 +1,19 @@
1
+
2
+ *,
3
+ *::before,
4
+ *::after {
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ body {
9
+ height: 100vh;
10
+ margin: 0;
11
+ overflow: hidden;
12
+ background: linear-gradient(135deg, #ffd2c1, #f9d0d3);
13
+ }
14
+
15
+ .scene {
16
+ position: absolute;
17
+ width: 100%;
18
+ height: 100vh;
19
+ }
@@ -0,0 +1,20 @@
1
+ // Copyright 2023 Scape Agency BV
2
+
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+
16
+ // Scenes
17
+ // ============================================================================
18
+
19
+
20
+ // @forward "bubble";
File without changes
@@ -0,0 +1,26 @@
1
+ // ============================================================================
2
+ // Beat
3
+ // ============================================================================
4
+
5
+ @keyframes animate_beat {
6
+ 0%, 90% { transform: scale($animate-scale-base); }
7
+ 45% { transform: scale($animate-scale-beat); }
8
+ }
9
+
10
+ @keyframes animate_beat_fade {
11
+ 0%, 100% {
12
+ opacity: $animate-opacity-fade;
13
+ transform: scale($animate-scale-base);
14
+ }
15
+ 50% {
16
+ opacity: 1;
17
+ transform: scale($animate-scale-beat-fade);
18
+ }
19
+ }
20
+
21
+ @keyframes animate_beat_double {
22
+ 0%, 100% { transform: scale($animate-scale-base); }
23
+ 25% { transform: scale($animate-scale-beat-double-small); }
24
+ 50% { transform: scale($animate-scale-beat-double-large); }
25
+ 75% { transform: scale($animate-scale-beat-double-small); }
26
+ }
File without changes
File without changes
@@ -0,0 +1,96 @@
1
+ // ============================================================================
2
+ // Poster
3
+ // ============================================================================
4
+
5
+ ////
6
+ ///
7
+ /// Cursors Maps Module
8
+ /// ===========================================================================
9
+ ///
10
+ /// @group Mouse
11
+ /// @author Scape Agency
12
+ /// @link https://move.gl
13
+ /// @since 0.1.0 initial release
14
+ /// @todo None
15
+ /// @see https://developer.mozilla.org/en-US/docs/Web/CSS/cursor
16
+ /// @access public
17
+ ///
18
+ ////
19
+
20
+
21
+ // ============================================================================
22
+ // Use
23
+ // ============================================================================
24
+
25
+
26
+
27
+ // ============================================================================
28
+ // Maps
29
+ // ============================================================================
30
+
31
+ ///
32
+ /// Cursor Styles Map
33
+ /// ---------------------------------------------------------------------------
34
+ ///
35
+ /// A map defining standard cursor styles for easy reference and extensibility.
36
+ /// Allows for uniform application of cursor styles across elements.
37
+ ///
38
+ $cursor_styles: (
39
+
40
+ // General
41
+ "auto": auto, // Default cursor
42
+ "default": default, // The platform-dependent default cursor. Typically an arrow.
43
+ "none": none, // No cursor is rendered.
44
+
45
+ // Links & Status
46
+ "context-menu": context-menu, // Indicates a context menu is available
47
+ "help": help, // Can be used for elements that provide additional information
48
+ "pointer": pointer, // Indicates a link. Typically an image of a pointing hand.
49
+ "progress": progress, // Indicates progress
50
+ "wait": wait, // Indicates a waiting state, often used for loading
51
+
52
+ // Selection
53
+ "cell": cell, // Indicates a cell or selectable item
54
+ "crosshair": crosshair, // Useful for precision elements, like in a drawing tool
55
+ "text": text, // The text can be selected. Typically the shape of an I-beam.
56
+ "vertical-text": vertical-text, // The vertical text can be selected. Typically the shape of a sideways I-beam.
57
+
58
+ // Drag & drop
59
+ "alias": alias, // Can indicate an alias of/shortcut to something
60
+ "copy": copy, // Indicates something can be copied
61
+ "move": move, // Something is to be moved.
62
+ "no-drop": no-drop, // Indicates that dropping is not allowed
63
+ "not-allowed": not-allowed, // Indicates an action is not allowed
64
+ "grab": grab, // Something can be grabbed (dragged to be moved).
65
+ "grabbing": grabbing, // Something is being grabbed (dragged to be moved).
66
+
67
+ // Resizing & Scrolling
68
+ "all-scroll": all-scroll, // Indicates scrolling in any direction
69
+ "col-resize": col-resize, // Indicates that a column can be resized
70
+ "row-resize": row-resize, // Indicates that a row can be resized
71
+ "n-resize": n-resize, // thin long arrow pointing towards the top Some edge is to be moved. For example, the se-resize cursor is used when the movement starts from the south-east corner of the box.
72
+ // In some environments, an equivalent bidirectional resize cursor is shown. For example, n-resize and s-resize are the same as ns-resize.
73
+ "e-resize": e-resize, // thin long arrow pointing towards the right
74
+ "s-resize": s-resize, // thin long arrow pointing down
75
+ "w-resize": w-resize, // thin long arrow pointing towards the left
76
+ "ne-resize": ne-resize, // thin long arrow pointing top-right
77
+ "nw-resize": nw-resize, // thin long arrow pointing top-left
78
+ "se-resize": se-resize, // thin long arrow pointing bottom-right
79
+ "sw-resize": sw-resize,
80
+ "ew-resize": ew-resize, // thin long arrow pointing left and right Bidirectional resize cursor.
81
+ "ns-resize": ns-resize, // thin long arrow pointing up and down
82
+ "nesw-resize": nesw-resize, // thin long arrow pointing both to the top-right and bottom-left
83
+ "nwse-resize": nwse-resize,
84
+
85
+ // Zooming
86
+ "zoom-in": zoom-in, // Indicates that something can be zoomed in
87
+ "zoom-out": zoom-out, // Indicates that something can be zoomed out
88
+
89
+ // Additions start here
90
+ "disabled": not-allowed,
91
+ "resize-vertical": ns-resize, // For vertical resizing
92
+ "resize-horizontal": ew-resize, // For horizontal resizing
93
+ "resize-diagonal-1": nwse-resize, // For diagonal resizing (top-left to bottom-right)
94
+ "resize-diagonal-2": nesw-resize, // For diagonal resizing (top-right to bottom-left)
95
+
96
+ );
@@ -0,0 +1,70 @@
1
+
2
+
3
+
4
+ // ============================================================================
5
+ // Accessibility
6
+ // ============================================================================
7
+
8
+ @use "../variables" as *;
9
+ @use "../mixins" as *;
10
+
11
+ /// Set the progress cursor for elements with `aria-busy="true"`.
12
+ [aria-busy='true'] {
13
+ cursor: progress;
14
+ }
15
+
16
+ /// Set the pointer cursor for elements that control other elements, indicated
17
+ /// by `aria-controls`.
18
+ [aria-controls] {
19
+ cursor: pointer;
20
+ }
21
+
22
+ /// Set the default cursor for disabled or non-interactive elements, indicated
23
+ /// by `aria-disabled="true"`.
24
+ [aria-disabled='true'] {
25
+ cursor: default;
26
+ }
27
+
28
+
29
+
30
+
31
+
32
+ // Accessibility Enhancements
33
+ // Using ARIA attributes to improve cursor semantics for better user experience
34
+ // in assistive technologies and for users with disabilities.
35
+
36
+ /// Mixin to apply cursor styles based on ARIA attributes.
37
+ /// @param {String} $property - The ARIA property (without 'aria-' prefix).
38
+ /// @param {String} $value - The value of the ARIA property.
39
+ /// @param {String} $cursor - The cursor style to apply.
40
+ ///
41
+ @mixin cursor_style($property, $value, $cursor) {
42
+ [#{'aria-' + $property}='#{ $value }'] {
43
+ cursor: $cursor;
44
+ }
45
+ }
46
+
47
+ /// Progress cursor for elements that are updating or being processed.
48
+ /// Applied to `aria-busy="true"` elements.
49
+ /// @group Accessibility
50
+ @include cursor_style('busy', 'true', progress);
51
+
52
+ /// Pointer cursor for interactive elements that control other elements.
53
+ /// Applied to elements with the `aria-controls` attribute.
54
+ /// @group Accessibility
55
+ @include cursor_style('controls', '', pointer);
56
+
57
+ /// Default cursor for elements that are disabled or non-interactive.
58
+ /// Applied to `aria-disabled="true"` elements.
59
+ /// @group Accessibility
60
+ @include cursor_style('disabled', 'true', default);
61
+
62
+ /// Not-allowed cursor for elements in an invalid state.
63
+ /// Example use case: form inputs with `aria-invalid="true"`.
64
+ /// @group Accessibility
65
+ @include cursor_style('invalid', 'true', not-allowed);
66
+
67
+ /// Help cursor for elements that provide additional information or guidance.
68
+ /// Example use case: elements with `aria-haspopup="true"`.
69
+ /// @group Accessibility
70
+ @include cursor_style('haspopup', 'true', help);
@@ -0,0 +1,51 @@
1
+
2
+
3
+ @use "../variables" as *;
4
+ @use "../mixins" as *;
5
+
6
+ /// Apply a fade-in animation to the `body` element using the `$boot-fadein-time` variable for the duration.
7
+ /// This animation smoothly transitions the opacity of the `body` from `$boot-fadein-opacity-start` to `$boot-fadein-opacity-end`.
8
+ /// @group Animation
9
+ ///
10
+ body {
11
+ -webkit-animation: fadein $boot-fadein-time;
12
+ -moz-animation: fadein $boot-fadein-time;
13
+ -ms-animation: fadein $boot-fadein-time;
14
+ -o-animation: fadein $boot-fadein-time;
15
+ animation: fadein $boot-fadein-time;
16
+ }
17
+
18
+ /// Keyframes for the `fadein` animation, transitioning opacity from `$boot-fadein-opacity-start` to `$boot-fadein-opacity-end`.
19
+ /// @group Animation
20
+ @keyframes fadein {
21
+ from { opacity: $boot-fadein-opacity-start; }
22
+ to { opacity: $boot-fadein-opacity-end; }
23
+ }
24
+
25
+ /// Webkit-specific keyframes for the `fadein` animation.
26
+ /// @group Animation
27
+ @-webkit-keyframes fadein {
28
+ from { opacity: $boot-fadein-opacity-start; }
29
+ to { opacity: $boot-fadein-opacity-end; }
30
+ }
31
+
32
+ /// Mozilla-specific keyframes for the `fadein` animation.
33
+ /// @group Animation
34
+ @-moz-keyframes fadein {
35
+ from { opacity: $boot-fadein-opacity-start; }
36
+ to { opacity: $boot-fadein-opacity-end; }
37
+ }
38
+
39
+ /// Microsoft-specific keyframes for the `fadein` animation.
40
+ /// @group Animation
41
+ @-ms-keyframes fadein {
42
+ from { opacity: $boot-fadein-opacity-start; }
43
+ to { opacity: $boot-fadein-opacity-end; }
44
+ }
45
+
46
+ /// Opera-specific keyframes for the `fadein` animation.
47
+ /// @group Animation
48
+ @-o-keyframes fadein {
49
+ from { opacity: $boot-fadein-opacity-start; }
50
+ to { opacity: $boot-fadein-opacity-end; }
51
+ }
@@ -0,0 +1,51 @@
1
+ ///
2
+ /// Scales an element when hovered, with a smooth transition.
3
+ ///
4
+ /// @name hover_scale
5
+ /// @param {Number} $scale-factor - The scale factor on hover (default: 1.05).
6
+ /// @param {Number|Unit} $duration - The duration of the scale transition (default: 0.3s).
7
+ /// @example scss - Usage
8
+ /// @include hover_scale(1.1, 0.4s);
9
+ ///
10
+ @mixin hover_scale($scale-factor: 1.05, $duration: 0.3s) {
11
+ transition: transform #{$duration} ease-in-out;
12
+
13
+ &:hover {
14
+ transform: scale(#{$scale-factor});
15
+ }
16
+ }
17
+
18
+ ///
19
+ /// Applies a scaling effect to an element on hover.
20
+ ///
21
+ /// @name hover_scale
22
+ /// @param {Number} $scale - The scaling factor (default: 1.1).
23
+ /// @param {Number|Unit} $duration - The duration of the transition (default: 0.3s).
24
+ /// @example scss - Usage
25
+ /// @include hover_scale(1.2, 0.5s);
26
+ ///
27
+ @mixin hover_scale($scale: 1.1, $duration: 0.3s) {
28
+ transition: transform $duration ease-in-out;
29
+
30
+ &:hover {
31
+ transform: scale($scale);
32
+ }
33
+ }
34
+
35
+ ///
36
+ /// Applies a smooth transition effect on hover for specified properties.
37
+ ///
38
+ /// @name hover_transition
39
+ /// @param {List} $properties - List of properties to transition (default: all).
40
+ /// @param {Number|Unit} $duration - Duration of the transition (default: 0.3s).
41
+ /// @param {String} $timing-function - Timing function for the transition (default: ease).
42
+ /// @example scss - Usage
43
+ /// @include hover_transition(color, background-color, 0.5s, ease-in-out);
44
+ ///
45
+ @mixin hover_transition($properties: all, $duration: 0.3s, $timing-function: ease) {
46
+ transition: #{$properties} #{$duration} #{$timing-function};
47
+
48
+ &:hover {
49
+ @content;
50
+ }
51
+ }
File without changes
@@ -0,0 +1,321 @@
1
+
2
+
3
+
4
+ // ============================================================================
5
+ // Selection
6
+ // ============================================================================
7
+
8
+
9
+ @use "../variables" as *;
10
+ @use "../mixins" as *;
11
+
12
+
13
+ @mixin selection {
14
+ ::selection { @content; } /*** Works on common browsers ***/
15
+ ::-moz-selection { @content; } /*** Works on common browsers ***/
16
+ ::-o-selection { @content; } /***For Other Browsers ***/
17
+ ::-webkit-selection { @content; } /*** For Webkit ***/
18
+ ::-ms-selection { @content; }
19
+ }
20
+
21
+ @include selection {
22
+ background-color: $color_04;
23
+ color: $color_02;
24
+ }
25
+
26
+
27
+ ::-moz-selection
28
+ {
29
+ color: var(--ptf-color-white);
30
+ background-color: var(--ptf-accent-1);
31
+ }
32
+
33
+ ::selection
34
+ {
35
+ color: var(--ptf-color-white);
36
+ background-color: var(--ptf-accent-1);
37
+ }
38
+
39
+ ::-moz-selection { background: #272727; color: #fff; }
40
+ ::selection { background: #272727; color: #fff; }
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+ // SCSS Mixin for Custom Text Selection
49
+ // ----------------------------------------------------------------------------
50
+ // conditionalThis mixin allows you to define custom colors for text selection,
51
+ // including the background color of the selection and the color of the text
52
+ // within the selection.
53
+
54
+ @mixin custom-selection($bg-color: #b3d4fc, $text-color: #fff) {
55
+ &::selection {
56
+ background-color: $bg-color; // Color of the background
57
+ color: $text-color; // Color of the text
58
+ }
59
+
60
+ // For compatibility with Mozilla Firefox
61
+ &::-moz-selection {
62
+ background-color: $bg-color; // Color of the background
63
+ color: $text-color; // Color of the text
64
+ }
65
+ }
66
+
67
+ // Usage Example
68
+ // You can use this mixin to apply custom selection styles globally or to specific elements.
69
+
70
+ // Global Custom Selection
71
+ // ----------------------------------------------------------------------------
72
+ // To apply a custom selection style globally, you can include the mixin
73
+ // within the html or body selector.
74
+
75
+
76
+ body {
77
+ @include custom-selection(#009688, #ffffff); // Teal background with white text
78
+ }
79
+ // Element-Specific Custom Selection
80
+ // To apply custom selection styles to specific elements, include the mixin within the specific element's selector.
81
+
82
+
83
+ p.custom-text-selection {
84
+ @include custom-selection(#ffeb3b, #000); // Yellow background with black text for paragraphs with the .custom-text-selection class
85
+ }
86
+ // Applying to Multiple Elements
87
+ // You can also apply the mixin to multiple elements by grouping selectors.
88
+
89
+
90
+ h1, h2, .highlight-text {
91
+ @include custom-selection(#673ab7, #fff); // Deep purple background with white text for all h1, h2, and .highlight-text class elements
92
+ }
93
+
94
+
95
+ // Conditional Text Selection Based on Parent or State
96
+ // You can conditionally apply text selection styles based on a parent element or a specific state, such as a class being applied to a parent element. This is useful for applying different selection styles in different sections of a page or in different components.
97
+
98
+
99
+ // Mixin for custom selection
100
+ // ----------------------------------------------------------------------------
101
+ @mixin custom-selection($bg-color, $text-color) {
102
+ &::selection {
103
+ background-color: $bg-color;
104
+ color: $text-color;
105
+ }
106
+ &::-moz-selection {
107
+ background-color: $bg-color;
108
+ color: $text-color;
109
+ }
110
+ }
111
+
112
+ // Applying conditional selection styles
113
+ .dark-mode {
114
+ .text {
115
+ @include custom-selection(#666, #eee); // Dark mode selection
116
+
117
+ &:hover {
118
+ @include custom-selection(#555, #fff); // Darker selection on hover
119
+ }
120
+ }
121
+ }
122
+
123
+ .light-mode {
124
+ .text {
125
+ @include custom-selection(#ddd, #333); // Light mode selection
126
+
127
+ &:hover {
128
+ @include custom-selection(#ccc, #222); // Lighter selection on hover
129
+ }
130
+ }
131
+ }
132
+
133
+
134
+ // Theming Support with SCSS Maps
135
+ // ----------------------------------------------------------------------------
136
+ // Leverage SCSS maps and loops to apply selection styles based on a theme
137
+ // system. This allows for easy theming and customization across your
138
+ // application.
139
+
140
+ $themes: (
141
+ "light": (
142
+ "selection-bg": #e0f7fa,
143
+ "selection-text": #00796b
144
+ ),
145
+ "dark": (
146
+ "selection-bg": #004d40,
147
+ "selection-text": #b2dfdb
148
+ )
149
+ );
150
+
151
+ @each $theme-name, $theme-properties in $themes {
152
+ .#{$theme-name}-theme {
153
+ @include custom-selection(map-get($theme-properties, "selection-bg"), map-get($theme-properties, "selection-text"));
154
+ }
155
+ }
156
+
157
+
158
+ // Dynamic Color Adjustments
159
+ // ----------------------------------------------------------------------------
160
+ // Utilize SCSS color functions to dynamically adjust selection colors based
161
+ // on a base color. This can be useful for creating selection styles that
162
+ // are always readable and maintain good contrast with the text.
163
+
164
+ @mixin dynamic-selection($base-color) {
165
+ $adjusted-bg-color: lighten($base-color, 20%);
166
+ $adjusted-text-color: darken($base-color, 50%);
167
+
168
+ &::selection {
169
+ background-color: $adjusted-bg-color;
170
+ color: $adjusted-text-color;
171
+ }
172
+ &::-moz-selection {
173
+ background-color: $adjusted-bg-color;
174
+ color: $adjusted-text-color;
175
+ }
176
+ }
177
+
178
+ .element {
179
+ @include dynamic-selection(#007bff); // Adjusts selection colors based on the provided base color
180
+ }
181
+
182
+
183
+ // Applying to Specific Elements with a Mixin
184
+ // ----------------------------------------------------------------------------
185
+ // Create a mixin that accepts both colors and a list of elements to apply
186
+ // the selection styles to. This approach reduces repetition and increases
187
+ // maintainability.
188
+
189
+ @mixin apply-selection-to-elements($elements, $bg-color, $text-color) {
190
+ @each $element in $elements {
191
+ #{$element}::selection {
192
+ background-color: $bg-color;
193
+ color: $text-color;
194
+ }
195
+ #{$element}::-moz-selection {
196
+ background-color: $bg-color;
197
+ color: $text-color;
198
+ }
199
+ }
200
+ }
201
+
202
+ @include apply-selection-to-elements(('p', 'h1', '.custom-class'), #ffcc80, #f44336);
203
+
204
+
205
+
206
+ // Animated Text Selection Background
207
+ // ----------------------------------------------------------------------------
208
+ // You can create a subtle animation effect for the text selection background using keyframes. This can add a dynamic visual cue when text is selected.
209
+
210
+ @mixin animated-selection($start-color, $end-color) {
211
+ @keyframes selectionBackground {
212
+ 0% { background-color: $start-color; }
213
+ 100% { background-color: $end-color; }
214
+ }
215
+
216
+ &::selection {
217
+ animation: selectionBackground 1s infinite alternate;
218
+ color: contrast($end-color);
219
+ }
220
+ &::-moz-selection {
221
+ animation: selectionBackground 1s infinite alternate;
222
+ color: contrast($end-color);
223
+ }
224
+ }
225
+
226
+ body {
227
+ @include animated-selection(lighten($primary-color, 40%), lighten($primary-color, 20%));
228
+ }
229
+
230
+
231
+ // Gradient Text Selection
232
+ // ----------------------------------------------------------------------------
233
+ // Applying a gradient to the text selection background can align with modern
234
+ // design trends. Note that this effect might not be consistent across all
235
+ // browsers due to rendering limitations.
236
+
237
+ @mixin gradient-selection($color1, $color2) {
238
+ &::selection {
239
+ background: linear-gradient(45deg, $color1, $color2);
240
+ color: mix($color1, $color2, 50%);
241
+ }
242
+ &::-moz-selection {
243
+ background: linear-gradient(45deg, $color1, $color2);
244
+ color: mix($color1, $color2, 50%);
245
+ }
246
+ }
247
+
248
+ .element {
249
+ @include gradient-selection(#FFD54F, #D500F9);
250
+ }
251
+
252
+
253
+ // Using Global Variables for Theme Consistency
254
+ // Defining global variables for your theme colors allows for consistent and maintainable style application across your project, including text selection.
255
+
256
+
257
+ // Define global theme colors
258
+ $theme-colors: (
259
+ primary: #6200ea,
260
+ secondary: #03dac6,
261
+ selection-bg: #B388FF,
262
+ selection-text: #6200ea,
263
+ );
264
+
265
+ @mixin theme-selection {
266
+ &::selection {
267
+ background-color: map-get($theme-colors, selection-bg);
268
+ color: map-get($theme-colors, selection-text);
269
+ }
270
+ &::-moz-selection {
271
+ background-color: map-get($theme-colors, selection-bg);
272
+ color: map-get($theme-colors, selection-text);
273
+ }
274
+ }
275
+
276
+ // Apply globally or to specific elements
277
+ body, .custom-text {
278
+ @include theme-selection;
279
+ }
280
+
281
+
282
+ // Pseudo-Element Selection Styles
283
+ // While the ::selection pseudo-element is primarily used for text, you
284
+ // can get creative by applying similar styles to other pseudo-elements
285
+ // for a cohesive look.
286
+ .element {
287
+ position: relative;
288
+
289
+ &::after {
290
+ content: "";
291
+ position: absolute;
292
+ width: 100%;
293
+ height: 2px;
294
+ background: $primary-color;
295
+ bottom: -5px;
296
+ left: 0;
297
+ }
298
+
299
+ &:hover::after {
300
+ @include gradient-selection(#FFD54F, #D500F9); // Apply gradient to the pseudo-element on hover
301
+ }
302
+ }
303
+
304
+ // Scoped Selection Styles with Mixins
305
+ // Creating a mixin to apply scoped selection styles can help manage different
306
+ // selection themes within various parts of your application.
307
+
308
+
309
+ @mixin scoped-selection($scope, $bg-color, $text-color) {
310
+ #{$scope}::selection {
311
+ background-color: $bg-color;
312
+ color: $text-color;
313
+ }
314
+ #{$scope}::-moz-selection {
315
+ background-color: $bg-color;
316
+ color: $text-color;
317
+ }
318
+ }
319
+
320
+ @include scoped-selection('.light-theme-text', #e0e0e0, #000);
321
+ @include scoped-selection('.dark-theme-text', #333, #fff);