Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add legacy color function migrator #260

Merged
merged 2 commits into from
Sep 19, 2024
Merged

Add legacy color function migrator #260

merged 2 commits into from
Sep 19, 2024

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
@jathak jathak merged commit c27792b into main Sep 19, 2024
17 checks passed
@jathak jathak deleted the color-migrator branch September 19, 2024 01:18
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