-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
} | ||
} | ||
|
||
final _colorUrl = Uri(scheme: 'sass', path: 'color'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: document this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/src/migrators/color.dart
Outdated
String? _colorModuleNamespace; | ||
Set<String> _usedNamespaces = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: document these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/src/migrators/color.dart
Outdated
case 'darken': | ||
_patchAdjust(node, channel: 'lightness', negate: true, space: 'hsl'); | ||
default: | ||
isMigrating == false; |
There was a problem hiding this comment.
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
isMigrating == false; | |
isMigrating = false; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
lib/src/migrators/color.dart
Outdated
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')); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/src/migrators/color.dart
Outdated
} | ||
|
||
/// Find an unused namespace for the sass:color module. | ||
String _findColorModuleNamespace() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/migrators/color/global.hrx
Outdated
@use "sass:color"; | ||
|
||
a { | ||
b: color.channel(gold, 'red', rgb); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.