Skip to content

Add legacy color function migrator#260

Merged
jathak merged 2 commits intomainfrom
color-migrator
Sep 19, 2024
Merged

Add legacy color function migrator#260
jathak merged 2 commits intomainfrom
color-migrator

Conversation

@jathak
Copy link
Member

@jathak jathak commented Sep 18, 2024

No description provided.

@jathak jathak requested a review from nex3 September 18, 2024 00:29
}
}

final _colorUrl = Uri(scheme: 'sass', path: 'color');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: document this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +41 to +42
String? _colorModuleNamespace;
Set<String> _usedNamespaces = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: document these

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

case 'darken':
_patchAdjust(node, channel: 'lightness', negate: true, space: 'hsl');
default:
isMigrating == false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be

Suggested change
isMigrating == false;
isMigrating = false;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also just return here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it was supposed to be assigning, but returning makes more sense

Comment on lines +100 to +107
if (_colorModuleNamespace == null) {
_colorModuleNamespace = _findColorModuleNamespace();
var asClause = _colorModuleNamespace == 'color'
? ''
: ' as $_colorModuleNamespace';
addPatch(Patch.insert(
node.span.file.location(0), '@use "sass:color"$asClause;\n\n'));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider pulling this into a _getOrAddColorModuleNamespace() function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

/// Find an unused namespace for the sass:color module.
String _findColorModuleNamespace() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider calling this _chooseColorModuleNamespace() to make it clearer that it's choosing a new namespace rather than finding one that's already loaded.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if (space != null) {
addPatch(patchAfter(adjustment, ', \$space: $space'));
}
case ArgumentInvocation(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: empty lines between long cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@use "sass:color";

a {
b: color.channel(gold, 'red', rgb);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have an explicit $space: on these as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jathak jathak requested a review from nex3 September 18, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants