Skip to content

Commit

Permalink
Fix colors docs page
Browse files Browse the repository at this point in the history
  • Loading branch information
sunarya-thito committed Dec 21, 2024
1 parent 93c1847 commit b53520f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
working-directory: './docs'

- name: Build
run: "flutter build web --base-href \"/shadcn_flutter/\" --wasm"
run: "flutter build web --wasm --base-href \"/shadcn_flutter/\""
working-directory: './docs'

- name: Deploy
Expand Down
11 changes: 6 additions & 5 deletions docs/lib/pages/docs/colors_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class _ColorsPageState extends State<ColorsPage> {
mainAxisSize: MainAxisSize.min,
children: [
AspectRatio(
aspectRatio: 0.82508734942,
aspectRatio: 16 / 19,
child: Clickable(
enabled: clickable,
mouseCursor:
Expand Down Expand Up @@ -149,15 +149,16 @@ class _ColorsPageState extends State<ColorsPage> {
BuildContext context, String name, ColorShades swatch) {
final theme = Theme.of(context);
List<Widget> children = [];
for (int i = 0; i < ColorShades.shadeValues.length; i++) {
final shade = ColorShades.shadeValues[i];
var shadeValues = ColorShades.shadeValues;
for (int i = 0; i < shadeValues.length; i++) {
final shade = shadeValues[i];
children.add(
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AspectRatio(
aspectRatio: 0.82508734942,
aspectRatio: 16 / 19,
child: Builder(builder: (context) {
return Clickable(
mouseCursor:
Expand Down Expand Up @@ -196,7 +197,7 @@ class _ColorsPageState extends State<ColorsPage> {
borderRadius: theme.borderRadiusMd,
border: shade == 500
? Border.all(
width: 3,
width: 30,
color: theme.colorScheme.foreground,
strokeAlign: BorderSide.strokeAlignOutside)
: null,
Expand Down
2 changes: 1 addition & 1 deletion docs/lib/pages/docs/introduction_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class _IntroductionPageState extends State<IntroductionPage> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
const Text('85 components and growing!').li(),
const Text('84 components and growing!').li(),
const Text(
'Supports both Material and Cupertino Widgets with theme being able to adapt to the current shadcn_flutter theme.')
.li(),
Expand Down
9 changes: 0 additions & 9 deletions lib/src/components/display/fade_scroll.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,3 @@ class _ScaleGradient extends GradientTransform {
}
}

Rect _inflateRect(Rect rect,
{double? left, double? top, double? right, double? bottom}) {
return Rect.fromLTRB(
rect.left - (left ?? 0),
rect.top - (top ?? 0),
rect.right + (right ?? 0),
rect.bottom + (bottom ?? 0),
);
}
8 changes: 5 additions & 3 deletions lib/src/components/layout/sortable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ class _SortableLayerState extends State<SortableLayer>
}

void _tick(Duration elapsed) {
List<_DropTransform> toRemove = [];
for (final drop in _activeDrops.value) {
drop.start ??= elapsed;
double progress = ((elapsed - drop.start!).inMilliseconds /
Expand All @@ -914,13 +915,14 @@ class _SortableLayerState extends State<SortableLayer>
progress = (widget.dropCurve ?? Curves.easeInOut).transform(progress);
if (progress >= 1) {
drop.state._hasClaimedDrop.value = false;
_activeDrops.mutate((value) {
value.remove(drop);
});
toRemove.add(drop);
} else {
drop.progress.value = progress;
}
}
_activeDrops.mutate((value) {
value.removeWhere((element) => toRemove.contains(element));
});
if (_activeDrops.value.isEmpty) {
_ticker.stop();
}
Expand Down
32 changes: 16 additions & 16 deletions lib/src/theme/color_scheme.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:collection';
import 'dart:ui';

import 'package:shadcn_flutter/shadcn_flutter.dart';
Expand Down Expand Up @@ -48,7 +49,7 @@ class ChartColorScheme {

class ColorShades implements Color, ColorSwatch {
static const int _step = 100;
static const List<int> _shadeValues = [
static const List<int> shadeValues = [
50,
100,
200,
Expand All @@ -61,7 +62,6 @@ class ColorShades implements Color, ColorSwatch {
900,
950
];
static List<int> get shadeValues => List.unmodifiable(_shadeValues);
final Map<int, Color> _colors;

ColorShades._() : _colors = {};
Expand All @@ -70,11 +70,11 @@ class ColorShades implements Color, ColorSwatch {
const ColorShades.raw(this._colors);

factory ColorShades.sorted(List<Color> colors) {
assert(colors.length == _shadeValues.length,
assert(colors.length == shadeValues.length,
'ColorShades.sorted: Invalid number of colors');
final slate = ColorShades._();
for (int i = 0; i < _shadeValues.length; i++) {
slate._colors[_shadeValues[i]] = colors[i];
for (int i = 0; i < shadeValues.length; i++) {
slate._colors[shadeValues[i]] = colors[i];
}
return slate;
}
Expand All @@ -86,7 +86,7 @@ class ColorShades implements Color, ColorSwatch {
int saturationStepUp = 0,
int lightnessStepDown = 8,
int lightnessStepUp = 9}) {
assert(_shadeValues.contains(base),
assert(shadeValues.contains(base),
'ColorShades.fromAccent: Invalid base value');
final hsl = HSLColor.fromColor(accent);
return ColorShades.fromAccentHSL(hsl,
Expand All @@ -104,10 +104,10 @@ class ColorShades implements Color, ColorSwatch {
int saturationStepUp = 0,
int lightnessStepDown = 8,
int lightnessStepUp = 9}) {
assert(_shadeValues.contains(base),
assert(shadeValues.contains(base),
'ColorShades.fromAccent: Invalid base value');
final slate = ColorShades._();
for (final key in _shadeValues) {
for (final key in shadeValues) {
double delta = (key - base) / _step;
double hueDelta = delta * (hueShift / 10);
double saturationDelta =
Expand All @@ -133,7 +133,7 @@ class ColorShades implements Color, ColorSwatch {
int lightnessStepUp = 9,
int lightnessStepDown = 8,
}) {
assert(_shadeValues.contains(base),
assert(shadeValues.contains(base),
'ColorShades.fromAccent: Invalid base value');
double delta = (targetBase - base) / _step;
double hueDelta = delta * (hueShift / 10);
Expand All @@ -150,7 +150,7 @@ class ColorShades implements Color, ColorSwatch {

factory ColorShades.fromMap(Map<int, Color> colors) {
final slate = ColorShades._();
for (final key in _shadeValues) {
for (final key in shadeValues) {
assert(colors.containsKey(key),
'ColorShades.fromMap: Missing value for $key');
slate._colors[key] = colors[key]!;
Expand Down Expand Up @@ -205,7 +205,7 @@ class ColorShades implements Color, ColorSwatch {
@override
ColorShades withAlpha(int a) {
Map<int, Color> colors = {};
for (final key in _shadeValues) {
for (final key in shadeValues) {
colors[key] = _colors[key]!.withAlpha(a);
}
return ColorShades._direct(colors);
Expand All @@ -216,7 +216,7 @@ class ColorShades implements Color, ColorSwatch {
Map<int, Color> colors = {};
// calculate the difference between the current blue value and the new value
int delta = b - blue;
for (final key in _shadeValues) {
for (final key in shadeValues) {
int safe = (_colors[key]!.blue + delta).clamp(0, 255);
colors[key] = _colors[key]!.withBlue(safe);
}
Expand All @@ -228,7 +228,7 @@ class ColorShades implements Color, ColorSwatch {
Map<int, Color> colors = {};
// calculate the difference between the current green value and the new value
int delta = g - green;
for (final key in _shadeValues) {
for (final key in shadeValues) {
int safe = (_colors[key]!.green + delta).clamp(0, 255);
colors[key] = _colors[key]!.withGreen(safe);
}
Expand All @@ -238,7 +238,7 @@ class ColorShades implements Color, ColorSwatch {
@override
Color withOpacity(double opacity) {
Map<int, Color> colors = {};
for (final key in _shadeValues) {
for (final key in shadeValues) {
colors[key] = _colors[key]!.scaleAlpha(opacity);
}
return ColorShades._direct(colors);
Expand All @@ -249,7 +249,7 @@ class ColorShades implements Color, ColorSwatch {
Map<int, Color> colors = {};
// calculate the difference between the current red value and the new value
int delta = r - red;
for (final key in _shadeValues) {
for (final key in shadeValues) {
int safe = (_colors[key]!.red + delta).clamp(0, 255);
colors[key] = _colors[key]!.withRed(safe);
}
Expand Down Expand Up @@ -289,7 +289,7 @@ class ColorShades implements Color, ColorSwatch {
double? blue,
ColorSpace? colorSpace}) {
Map<int, Color> colors = {};
for (final key in _shadeValues) {
for (final key in shadeValues) {
colors[key] = _colors[key]!.withValues(
alpha: alpha,
red: red,
Expand Down

0 comments on commit b53520f

Please sign in to comment.