Skip to content

Commit

Permalink
Fix documentation (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante authored Jun 25, 2024
1 parent 05620be commit 53b7b19
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 175 deletions.
2 changes: 1 addition & 1 deletion docs/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NEXT_PUBLIC_DEMO_URL=https://demo.master.forui.dev/card
NEXT_PUBLIC_DEMO_URL=https://dev.demo.forui.dev
9 changes: 5 additions & 4 deletions docs/components/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import {useTheme} from "nextra-theme-docs";
interface Props {
name: string;
variant?: string;
height?: number;
query: Record<string, string>;
}

export function Widget({name, variant = 'default', query}: Props) {
export function Widget({name, variant = 'default', height = 200, query}: Props) {
const {resolvedTheme} = useTheme();
query['theme'] = resolvedTheme;
query['theme'] = `zinc-${resolvedTheme}`;

const url = process.env['NEXT_PUBLIC_DEMO_URL'];

return (
<iframe
className="w-full border rounded dark:border-neutral-400/20"
style={{height: `${height}px`}}
src={`${url}/${name}/${variant}?${new URLSearchParams(query).toString()}`}
width={0}
height={0}
/>
);
}
2 changes: 1 addition & 1 deletion docs/pages/docs/dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A modal dialog interrupts the user with important content and expects a response

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='dialog' query={{vertical: "false"}}/>
<Widget name='dialog' query={{vertical: "false"}} height={400}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/scaffold.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Creates a visual scaffold for Forui widgets.

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='scaffold' query={{}}/>
<Widget name='scaffold' query={{}} height={600}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
Expand Down
6 changes: 5 additions & 1 deletion docs/pages/docs/separator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ Visually or semantically separates content.

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='separator' query={{}}/>
<Widget name='separator' query={{}} height={300}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
final theme = context.theme;
final colorScheme = theme.colorScheme;
final typography = theme.typography;
Padding(
padding: const EdgeInsets.all(16),
child: Column(
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/switch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ A switch that allows the user to toggle between checked and unchecked.
ValueListenableBuilder(
valueListenable: notifier,
builder: (context, _, __) => FSwitch(
value: notifier.value,
builder: (context, value, __) => FSwitch(
value: value,
onChanged: (value) => notifier.value = value,
),
);
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/tabs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A set of layered sections of content—known as tab entries—that are displayed

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='tabs' query={{}}/>
<Widget name='tabs' query={{}} height={500}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
Expand Down
2 changes: 1 addition & 1 deletion forui/lib/src/widgets/header/header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ final class FHeaderStyle with Diagnosticable {
height: 1,
),
action = FHeaderActionStyle.inherit(colorScheme: colorScheme),
padding = style.pagePadding.copyWith(bottom: 10);
padding = style.pagePadding.copyWith(bottom: 15);

/// Returns a copy of this [FHeaderStyle] with the given properties replaced.
///
Expand Down
5 changes: 1 addition & 4 deletions forui/lib/src/widgets/switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,7 @@ final class FSwitchStyle with Diagnosticable {
: checkedColor = colorScheme.primary,
uncheckedColor = colorScheme.border,
thumbColor = colorScheme.background,
focusColor = HSLColor.fromColor(colorScheme.primary.withOpacity(0.80))
.withLightness(0.69)
.withSaturation(0.835)
.toColor();
focusColor = colorScheme.primary;

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
Expand Down
21 changes: 11 additions & 10 deletions samples/lib/sample_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ abstract class SampleScaffold extends StatelessWidget {
SampleScaffold({
String theme = 'zinc-light',
super.key,
}):
theme = themes[theme]!;
}) : theme = themes[theme]!;

@override
Widget build(BuildContext context) => FTheme(
data: theme,
child: FScaffold(

content: Center(
child: child(context),
),
),
);
data: theme,
child: FScaffold(
content: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 600),
child: child(context),
),
),
),
);

Widget child(BuildContext context);
}
86 changes: 48 additions & 38 deletions samples/lib/widgets/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,56 @@ class ScaffoldPage extends SampleScaffold {
});

@override
Widget child(BuildContext context) => FScaffold(
header: FHeader(
title: 'Settings',
actions: [
FHeaderAction(
icon: FAssets.icons.ellipsis,
onPress: () {},
),
],
),
content: ListView(
children: [
FCard(
title: 'Account',
subtitle: 'Make changes to your account here. Click save when you are done.',
child: Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(
children: [
const FTextField(
label: 'Name',
hint: 'John Renalo',
),
const SizedBox(height: 10),
const FTextField(
label: 'Email',
hint: '[email protected]',
),
Padding(
padding: const EdgeInsets.only(top: 24, bottom: 16),
child: FButton(
label: 'Save',
onPress: () {},
Widget child(BuildContext context) => Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 30),
SizedBox(
height: 420,
child: FScaffold(
header: FHeader(
title: 'Settings',
actions: [
FHeaderAction(
icon: FAssets.icons.ellipsis,
onPress: () {},
),
],
),
content: Column(
children: [
const SizedBox(height: 5),
FCard(
title: 'Account',
subtitle: 'Make changes to your account here. Click save when you are done.',
child: Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(
children: [
const FTextField(
label: 'Name',
hint: 'John Renalo',
),
const SizedBox(height: 10),
const FTextField(
label: 'Email',
hint: '[email protected]',
),
Padding(
padding: const EdgeInsets.only(top: 24, bottom: 16),
child: FButton(
label: 'Save',
onPress: () {},
),
),
],
),
),
],
),
),
],
),
),
],
),
);
),
],
);
}
78 changes: 41 additions & 37 deletions samples/lib/widgets/separator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,54 @@ class SeparatorPage extends SampleScaffold {

@override
Widget child(BuildContext context) {
final theme = context.theme;
final colorScheme = theme.colorScheme;
final typography = theme.typography;

return Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Flutter Forui',
style: typography.xl2.copyWith(
color: colorScheme.foreground,
fontWeight: FontWeight.w600,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 300),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Flutter Forui',
style: typography.xl2.copyWith(
color: colorScheme.foreground,
fontWeight: FontWeight.w600,
),
),
),
Text(
'An open-source widget library.',
style: typography.sm.copyWith(color: colorScheme.mutedForeground),
),
const FSeparator(),
SizedBox(
height: 30,
child: Row(
children: [
Text(
'Blog',
style: typography.sm.copyWith(color: colorScheme.foreground),
),
const FSeparator(vertical: true),
Text(
'Docs',
style: typography.sm.copyWith(color: colorScheme.foreground),
),
const FSeparator(vertical: true),
Text(
'Source',
style: typography.sm.copyWith(color: colorScheme.foreground),
),
],
Text(
'An open-source widget library.',
style: typography.sm.copyWith(color: colorScheme.mutedForeground),
),
),
],
const FSeparator(),
SizedBox(
height: 30,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Blog',
style: typography.sm.copyWith(color: colorScheme.foreground),
),
const FSeparator(vertical: true),
Text(
'Docs',
style: typography.sm.copyWith(color: colorScheme.foreground),
),
const FSeparator(vertical: true),
Text(
'Source',
style: typography.sm.copyWith(color: colorScheme.foreground),
),
],
),
),
],
),
),
);
}
Expand Down
6 changes: 3 additions & 3 deletions samples/lib/widgets/switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class SwitchPage extends SampleScaffold {
padding: const EdgeInsets.all(16),
child: ValueListenableBuilder(
valueListenable: notifier,
builder: (context, _, __) => FSwitch(
value: true,
builder: (context, value, __) => FSwitch(
value: value,
autofocus: true,
onChanged: (value) {},
onChanged: (value) => notifier.value = value,
),
),
);
Expand Down
Loading

0 comments on commit 53b7b19

Please sign in to comment.