zed/script/storybook

61 lines
1,010 B
Text
Raw Normal View History

#!/bin/bash
2023-12-14 16:42:08 +00:00
options=(
"auto_height_editor"
"avatar"
"button"
"checkbox"
"context_menu"
"cursor"
"disclosure"
"focus"
"icon"
"icon_button"
"keybinding"
"label"
"list"
"list_header"
"list_item"
"overflow_scroll"
"scroll"
"tab"
"tab_bar"
"text"
"viewport_units"
"z_index"
"picker"
)
2023-12-14 16:42:08 +00:00
run_story() {
echo "Running story: $1"
cargo run -p storybook2 -- "$1"
}
if [ "$#" -gt 0 ]; then
story_arg="$1"
# Add prefix 'components/' if not present
if [[ $story_arg != components/* ]]; then
story_arg="components/$story_arg"
fi
# Check if the provided story is a valid option
for opt in "${options[@]}"; do
if [[ "components/$opt" == "$story_arg" ]]; then
run_story "$story_arg"
exit
fi
done
echo "Invalid story name: $1"
exit 1
fi
2023-12-14 16:42:08 +00:00
prompt="Please select a story:"
PS3="$prompt "
select story in "${options[@]}"; do
if [[ -n $story ]]; then
run_story "components/$story"
break
else
echo "Invalid option"
fi
done