flex_example_test.go 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package layout_test
  2. import (
  3. "fmt"
  4. "github.com/sst/opencode/internal/layout"
  5. )
  6. func ExampleRender_withGap() {
  7. // Create a horizontal layout with 3px gap between items
  8. result := layout.Render(
  9. layout.FlexOptions{
  10. Direction: layout.Row,
  11. Width: 30,
  12. Height: 1,
  13. Gap: 3,
  14. },
  15. layout.FlexItem{View: "Item1"},
  16. layout.FlexItem{View: "Item2"},
  17. layout.FlexItem{View: "Item3"},
  18. )
  19. fmt.Println(result)
  20. // Output: Item1 Item2 Item3
  21. }
  22. func ExampleRender_withGapAndJustify() {
  23. // Create a horizontal layout with gap and space-between justification
  24. result := layout.Render(
  25. layout.FlexOptions{
  26. Direction: layout.Row,
  27. Width: 30,
  28. Height: 1,
  29. Gap: 2,
  30. Justify: layout.JustifySpaceBetween,
  31. },
  32. layout.FlexItem{View: "A"},
  33. layout.FlexItem{View: "B"},
  34. layout.FlexItem{View: "C"},
  35. )
  36. fmt.Println(result)
  37. // Output: A B C
  38. }