sass-guidelines icon indicating copy to clipboard operation
sass-guidelines copied to clipboard

Default namespace?

Open robsonsobral opened this issue 2 years ago • 7 comments

One topic per issue?


I've been using my on my tests:

@use '../abstracts' as my;

What do you think, @Elrendio || @KittyGiraudel ?

robsonsobral avatar Oct 27 '21 18:10 robsonsobral

Hello! ⭐

Do you mind giving an example of how you use an exposed utility once imported? :)

KittyGiraudel avatar Oct 28 '21 14:10 KittyGiraudel

Not at all! Take a look!

@use 'config';

@forward 'config';
@forward 'functions' with (
  $my-base-url: config.$base-url,
  $my-breakpoints: config.$breakpoints,
  $my-font-weights: config.$font-weights,
  $my-gutter: config.$gutter,
  $my-palette: config.$palette,
);
@forward 'mixins';

I'm trying to start the discussion for the next version. Maybe I remember of another topics to address.

robsonsobral avatar Oct 29 '21 00:10 robsonsobral

Ops! I'm sorry. I misunderstood your question!

I use them this way:

.foo {
  @include my.exposed-mixin('bar');
}

robsonsobral avatar Oct 29 '21 01:10 robsonsobral

Ah I see. I’m just remembering how this thing works. Wondering whether or not we should suggest a default namespace. I don’t dislike my, but it might not always be suitable. For instance, team-based authoring might not be super comfortable with a namespace using first person, and our is just silly. 😅

Maybe utils or something? Or perhaps we should just not enforce it in any way?

KittyGiraudel avatar Oct 30 '21 09:10 KittyGiraudel

I chose my because I was talking to a PERL developer at the time.

I just wanted to feel how would be to code using the namespace idea on my styles. On the bright side, we can avoid collisions between local and global members, like my.column-width and width. On the dark side, it's annoying to call your definitions file again and again. However, we can't avoid the last part.

robsonsobral avatar Oct 31 '21 02:10 robsonsobral

I came to the conclusion that to use a namespace is absolutely necessary, to avoid making a mess with new CSS features, like image-set().

robsonsobral avatar Dec 06 '21 13:12 robsonsobral

I think I would be more in favour of smaller, more focused modules that are namespaced with a singular noun that logically identifies what the modules provides. For example, @use 'query'; for utilities that handle media queries. Or, once developed enough @use 'breakpoint'; for utilities handling breakpoints.

roydukkey avatar Jan 03 '22 15:01 roydukkey