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

fix: input hint alignment #261

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.19.0

- **BREAKING CHANGE**: `ShadInput` placeholder alignment. Removed `placeholder` in favor of `hintText` which is now of type `String`. This applies also to `ShadInputFormField`.
- **BREAKING CHANGE**: Rename `searchPlaceholder` into `searchHintText` in `ShadSelect` and `ShadSelectTheme`.
- **BREAKING CHANGE**: Rename `hourPlaceholder` into `hourHintText`, `minutePlaceholder` into `minuteHintText`, `secondPlaceholder` into `secondHintText` in `ShadTimePicker` and `ShadTimePickerTheme`.
- **FIX**: Add `assert` to prevent `selected` date of `ShadCalendar` to be outside the `fromMonth:toMonth` range.

## 0.18.1

- **FIX**: Set `ShadCard` clipBehavior to `Clip.antialias`, add `clipBehavior` to `ShadCard` and `ShadCardTheme`.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/Components/card.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CardProject extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text('Name'),
const ShadInput(placeholder: Text('Name of your project')),
const ShadInput(hintText: 'Name of your project'),
const SizedBox(height: 6),
const Text('Framework'),
ShadSelect<String>(
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/Components/form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _FormPageState extends State<FormPage> {
ShadInputFormField(
id: 'username',
label: const Text('Username'),
placeholder: const Text('Enter your username'),
hintText: 'Enter your username',
description: const Text('This is your public display name.'),
validator: (v) {
if (v.length < 2) {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/Components/input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Displays a form input field or a component that looks like an input field.
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 320),
child: const ShadInput(
placeholder: Text('Email'),
hintText: 'Email',
keyboardType: TextInputType.emailAddress,
),
),
Expand All @@ -40,7 +40,7 @@ class _PasswordInputState extends State<PasswordInput> {
@override
Widget build(BuildContext context) {
return ShadInput(
placeholder: const Text('Password'),
hintText: 'Password',
obscureText: obscure,
prefix: const Padding(
padding: EdgeInsets.all(4.0),
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/Components/select.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class _SelectWithSearchState extends State<SelectWithSearch> {
maxWidth: 300,
placeholder: const Text('Select framework...'),
onSearchChanged: (value) => setState(() => searchValue = value),
searchPlaceholder: const Text('Search framework'),
searchHintText: 'Search framework',
options: [
if (filteredFrameworks.isEmpty)
const Padding(
Expand Down
6 changes: 3 additions & 3 deletions example/lib/common/properties/string_property.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class MyStringProperty extends StatelessWidget {
required this.label,
required this.initialValue,
required this.onChanged,
this.placeholder,
this.hintText,
this.inputFormatters,
});

final String label;
final Widget? placeholder;
final String? hintText;
final String? initialValue;
final ValueChanged<String>? onChanged;
final List<TextInputFormatter>? inputFormatters;
Expand All @@ -30,7 +30,7 @@ class MyStringProperty extends StatelessWidget {
ShadInput(
initialValue: initialValue,
onChanged: onChanged,
placeholder: placeholder,
hintText: hintText,
inputFormatters: inputFormatters,
)
],
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class _MainPageState extends State<MainPage> {
return Scaffold(
appBar: MyAppBar(
titleWidget: ShadInput(
placeholder: const Text('Search ShadcnUI component'),
hintText: 'Search ShadcnUI component',
onChanged: search.set,
),
),
Expand Down
9 changes: 5 additions & 4 deletions example/lib/pages/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class CalendarPage extends StatefulWidget {
}

class _CalendarPageState extends State<CalendarPage> {
final today = DateTime.now();
DateTime? selected = DateTime.now();
bool reverseMonths = false;
ShadCalendarCaptionLayout captionLayout = ShadCalendarCaptionLayout.label;
Expand Down Expand Up @@ -110,8 +111,8 @@ class _CalendarPageState extends State<CalendarPage> {
Text('Single', style: theme.textTheme.h4),
ShadCalendar(
selected: selected,
fromMonth: DateTime(2023),
toMonth: DateTime(2024, 12),
fromMonth: DateTime(today.year),
toMonth: DateTime(today.year, 12),
hideNavigation: hideNavigation,
captionLayout: captionLayout,
onMonthChanged: (date) {
Expand All @@ -127,8 +128,8 @@ class _CalendarPageState extends State<CalendarPage> {
Text('Multiple', style: theme.textTheme.h4),
ShadCalendar.multiple(
numberOfMonths: 2,
fromMonth: DateTime(2024),
toMonth: DateTime(2024, 12),
fromMonth: DateTime(today.year),
toMonth: DateTime(today.year, 12),
onChanged: (dates) {},
min: 5,
max: 10,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _CardPageState extends State<CardPage> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text('Name'),
const ShadInput(placeholder: Text('Name of your project')),
const ShadInput(hintText: 'Name of your project'),
const SizedBox(height: 6),
const Text('Framework'),
ShadSelect<String>(
Expand Down
16 changes: 14 additions & 2 deletions example/lib/pages/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,25 @@ class _InputPageState extends State<InputPage> {
),
],
children: [
SizedBox(
width: 40,
child: ShadInput(
padding: const EdgeInsets.symmetric(vertical: 8),
textAlign: TextAlign.center,
hintText: '0',
style: const TextStyle(fontSize: 12),
hintStyle: const TextStyle(fontSize: 12),
enabled: enabled,
keyboardType: TextInputType.emailAddress,
),
),
ShadInput(
placeholder: const Text('Email'),
hintText: 'Email',
enabled: enabled,
keyboardType: TextInputType.emailAddress,
),
ShadInput(
placeholder: const Text('Password'),
hintText: 'Password',
enabled: enabled,
obscureText: obscure,
prefix: const Padding(
Expand Down
4 changes: 2 additions & 2 deletions example/lib/pages/input_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _InputFormFieldPageState extends State<InputFormFieldPage> {
MyStringProperty(
label: 'Form Initial Value',
initialValue: initialValue,
placeholder: const Text('Name'),
hintText: 'Name',
onChanged: (value) {
setState(() {
value.isEmpty ? initialValue = null : initialValue = value;
Expand All @@ -74,7 +74,7 @@ class _InputFormFieldPageState extends State<InputFormFieldPage> {
id: 'username',
prefix: const Icon(LucideIcons.user),
label: const Text('Username'),
placeholder: const Text('Enter your username'),
hintText: 'Enter your username',
description: const Text('This is your public display name.'),
validator: (v) {
if (v.length < 2) {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/input_otp_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _InputOTPFormFieldPageState extends State<InputOTPFormFieldPage> {
MyStringProperty(
label: 'Form Initial Value',
initialValue: initialValue,
placeholder: const Text('OTP initial value'),
hintText: 'OTP initial value',
onChanged: (value) {
setState(() {
value.isEmpty ? initialValue = null : initialValue = value;
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class _SelectPageState extends State<SelectPage> {
maxWidth: 300,
placeholder: const Text('Select framework...'),
onSearchChanged: (value) => setState(() => searchValue = value),
searchPlaceholder: const Text('Search framework'),
searchHintText: 'Search framework',
options: [
if (filteredFrameworks.isEmpty)
const Padding(
Expand Down
5 changes: 5 additions & 0 deletions example/lib/pages/time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class TimePickerPage extends StatelessWidget {
padding: EdgeInsets.only(left: 8, top: 14),
child: Icon(LucideIcons.clock4),
),
// fieldWidth: 40,
// spacing: 8,
// style: TextStyle(fontSize: 12),
// placeholderStyle: TextStyle(fontSize: 12),
// fieldPadding: EdgeInsets.zero,
onChanged: (time) {
print('time: $time');
},
Expand Down
3 changes: 2 additions & 1 deletion lib/src/components/avatar.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:shadcn_ui/src/theme/data.dart';
import 'package:shadcn_ui/src/theme/theme.dart';
import 'package:shadcn_ui/src/utils/debug_check.dart';
import 'package:universal_image/universal_image.dart';

Expand Down
14 changes: 14 additions & 0 deletions lib/src/components/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,20 @@ class _ShadCalendarState extends State<ShadCalendar> {
'When fixedWeeks is true, showOutsideDays must be true',
);

assert(
widget.selected == null ||
(widget.fromMonth == null ||
widget.selected!.isSameDayOrGreatier(widget.fromMonth!)),
'The selected date cannot be before fromMonth',
);

assert(
widget.selected == null ||
(widget.toMonth == null ||
widget.selected!.isSameDayOrLower(widget.toMonth!)),
'The selected date cannot be greater than toMonth',
);

final theme = ShadTheme.of(context);

final effectiveCaptionLayout =
Expand Down
8 changes: 3 additions & 5 deletions lib/src/components/form/fields/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ShadInputFormField extends ShadFormBuilderField<String> {
super.valueTransformer,
super.onReset,
ShadDecoration? decoration,
Widget? placeholder,
String? hintText,
TextMagnifierConfiguration magnifierConfiguration =
TextMagnifierConfiguration.disabled,
TextInputType? keyboardType,
Expand Down Expand Up @@ -87,7 +87,6 @@ class ShadInputFormField extends ShadFormBuilderField<String> {
MainAxisAlignment? mainAxisAlignment,
CrossAxisAlignment? crossAxisAlignment,
TextStyle? placeholderStyle,
Alignment? placeholderAlignment,
EdgeInsets? inputPadding,
double? gap,
}) : super(
Expand Down Expand Up @@ -148,7 +147,7 @@ class ShadInputFormField extends ShadFormBuilderField<String> {
enableInteractiveSelection: enableInteractiveSelection,
undoController: undoController,
spellCheckConfiguration: spellCheckConfiguration,
placeholder: placeholder,
hintText: hintText,
onPressed: onPressed,
onPressedAlwaysCalled: onPressedAlwaysCalled,
onPressedOutside: onPressedOutside,
Expand All @@ -167,8 +166,7 @@ class ShadInputFormField extends ShadFormBuilderField<String> {
suffix: suffix,
mainAxisAlignment: mainAxisAlignment,
crossAxisAlignment: crossAxisAlignment,
placeholderStyle: placeholderStyle,
placeholderAlignment: placeholderAlignment,
hintStyle: placeholderStyle,
inputPadding: inputPadding,
gap: gap,
);
Expand Down
16 changes: 8 additions & 8 deletions lib/src/components/form/fields/select.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ShadSelectFormField<T> extends ShadFormBuilderField<T> {
ImageFilter? filter,
Widget? searchDivider,
Widget? searchInputPrefix,
Widget? searchPlaceholder,
String? searchHintText,
EdgeInsets? searchPadding,
Widget? search,
bool? clearSearchOnClose,
Expand Down Expand Up @@ -198,7 +198,7 @@ class ShadSelectFormField<T> extends ShadFormBuilderField<T> {
onSearchChanged: onSearchChanged,
searchDivider: searchDivider,
searchInputPrefix: searchInputPrefix,
searchPlaceholder: searchPlaceholder,
searchHintText: searchHintText,
searchPadding: searchPadding,
search: search,
clearSearchOnClose: clearSearchOnClose,
Expand Down Expand Up @@ -248,7 +248,7 @@ class ShadSelectFormField<T> extends ShadFormBuilderField<T> {
ImageFilter? filter,
Widget? searchDivider,
Widget? searchInputPrefix,
Widget? searchPlaceholder,
String? searchHintText,
EdgeInsets? searchPadding,
Widget? search,
bool? clearSearchOnClose,
Expand Down Expand Up @@ -311,7 +311,7 @@ class ShadSelectFormField<T> extends ShadFormBuilderField<T> {
onSearchChanged: onSearchChanged,
searchDivider: searchDivider,
searchInputPrefix: searchInputPrefix,
searchPlaceholder: searchPlaceholder,
searchHintText: searchHintText,
searchPadding: searchPadding,
search: search,
clearSearchOnClose: clearSearchOnClose,
Expand Down Expand Up @@ -459,7 +459,7 @@ class ShadSelectMultipleFormField<T> extends ShadFormBuilderField<List<T>> {
ImageFilter? filter,
Widget? searchDivider,
Widget? searchInputPrefix,
Widget? searchPlaceholder,
String? searchHintText,
EdgeInsets? searchPadding,
Widget? search,
bool? clearSearchOnClose,
Expand Down Expand Up @@ -507,7 +507,7 @@ class ShadSelectMultipleFormField<T> extends ShadFormBuilderField<List<T>> {
onSearchChanged: onSearchChanged,
searchDivider: searchDivider,
searchInputPrefix: searchInputPrefix,
searchPlaceholder: searchPlaceholder,
searchHintText: searchHintText,
searchPadding: searchPadding,
search: search,
clearSearchOnClose: clearSearchOnClose,
Expand Down Expand Up @@ -555,7 +555,7 @@ class ShadSelectMultipleFormField<T> extends ShadFormBuilderField<List<T>> {
ImageFilter? filter,
Widget? searchDivider,
Widget? searchInputPrefix,
Widget? searchPlaceholder,
String? searchHintText,
EdgeInsets? searchPadding,
Widget? search,
bool? clearSearchOnClose,
Expand Down Expand Up @@ -605,7 +605,7 @@ class ShadSelectMultipleFormField<T> extends ShadFormBuilderField<List<T>> {
onSearchChanged: onSearchChanged,
searchDivider: searchDivider,
searchInputPrefix: searchInputPrefix,
searchPlaceholder: searchPlaceholder,
searchHintText: searchHintText,
searchPadding: searchPadding,
search: search,
clearSearchOnClose: clearSearchOnClose,
Expand Down
Loading
Loading