Skip to content

Commit

Permalink
component library docs
Browse files Browse the repository at this point in the history
  • Loading branch information
FlurinBruehwilerCMI committed Apr 29, 2024
1 parent 3f200a5 commit 070b37e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Flamui/Layouting/ConstraintSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public static class ConstraintSolver
{
public static void Solve(Span<Constraint> constraints, float remainingSpace)
{
var percentage = GetRemainingPercentage(ref unsolved);
// var percentage = GetRemainingPercentage(ref unsolved);

var sizePerPercentage = GetSizePerPercentage(percentage, remainingSpace);
// var sizePerPercentage = GetSizePerPercentage(percentage, remainingSpace);
}

private static float GetRemainingPercentage(ref Span<Constraint> unsolved)
Expand Down
2 changes: 2 additions & 0 deletions Flamui/Layouting/FlexContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public BoxSize Layout(BoxConstraint constraint)


}

return new BoxSize();
}

private float GetSizePerPercentage(float totalPercentage, float availableSize)
Expand Down
49 changes: 49 additions & 0 deletions docs/ComponentLibrary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Component Library
Flamui has a component library (Flamui.Components).

## DropDown
The dropdown is generic, so you can pass any type as the option, the .ToString() method will be used for the display name.

```csharp
var dd = ui.CreateDropDown(_selectedOption);
dd.Component.Option("Mark");
dd.Component.Option("Johnny");
dd.Component.Option("Frank");
dd.Component.Option("Linus");
dd.Build(out _selectedOption);
```
## Button
```csharp
ui.Button("Click me");

ui.Button("Button with options", primary: false, focusable: true);
```

## Input
The input component can't receive focus automatically, you need to pass in a boolean indicating whether it has focus or not.

```csharp
private string _content = "";

//an input that has allways focus
ui.Input(ref _content, hasFocus: true);
```

//an input with a div as a wrapper to act as the "hitbox"
```csharp
private string _content = "";

using(var div = ui.Div().Width(100).Height(30))
{
ui.Input(ref _content, div.HasFocus);
}
```

## StyledInput
A styled Input component that also handles focus etc.

```csharp
private string _content = "";

ui.StyledInput(ref _content, placeholder: "Please type");
```

0 comments on commit 070b37e

Please sign in to comment.