From c0a3504c9a3106b5df83da209681a68c1e7e457c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatriz=20Sopen=CC=83a=20Merino?= Date: Tue, 22 Oct 2024 13:45:37 +0200 Subject: [PATCH] refactor(sass): move `contains` function to a separate file and update imports accordingly Error: - The `functions` and `mixins` must be in separate files. Solution: - Move the `contains` function from `_tools-media.scss` to a new file `_tools-contains.scss` for better separation of concerns. - Update `tools/_tools-media.scss` to remove the `contains` function and keep only media query mixins. - Update `styles.scss` to include the new `tools/_tools-contains.scss` file using `@forward`, allowing better separation of functions and mixins. --- src/assets/scss/styles.scss | 1 + src/assets/scss/tools/_tools-contains.scss | 8 ++++++++ src/assets/scss/tools/_tools-media.scss | 6 +----- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 src/assets/scss/tools/_tools-contains.scss diff --git a/src/assets/scss/styles.scss b/src/assets/scss/styles.scss index d286ec6d..5aaff904 100644 --- a/src/assets/scss/styles.scss +++ b/src/assets/scss/styles.scss @@ -9,4 +9,5 @@ // TOOLS // ---------------------------------------------------------------------- +@forward "tools/tools-contains"; @forward "tools/tools-media"; diff --git a/src/assets/scss/tools/_tools-contains.scss b/src/assets/scss/tools/_tools-contains.scss new file mode 100644 index 00000000..91e9ea89 --- /dev/null +++ b/src/assets/scss/tools/_tools-contains.scss @@ -0,0 +1,8 @@ +// TOOLS - FUNCTIONS +// CONTAINS +// ================================================= +@use "sass:list"; + +@function contains($list, $item) { + @return list.index($list, $item) != null; +} diff --git a/src/assets/scss/tools/_tools-media.scss b/src/assets/scss/tools/_tools-media.scss index 45c33a8a..8b693810 100644 --- a/src/assets/scss/tools/_tools-media.scss +++ b/src/assets/scss/tools/_tools-media.scss @@ -1,16 +1,12 @@ // TOOLS - MIXINS // MEDIA // ================================================= -@use "sass:list"; @use "sass:map"; @use "sass:math"; @use "sass:meta"; +@use "../tools/tools-contains" as *; @use "../settings/settings-breakpoints" as *; -@function contains($list, $item) { - @return list.index($list, $item) != null; -} - @mixin media($breakpoint, $rule: "max", $dimension: "width") { $rules: "max", "min"; $dimensions: "width", "height";