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

docs: Metrics storybook design #1462

Closed
wants to merge 37 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a55f8f7
Add architecture and user interface sections to the storybook design
solid-maxim Jun 15, 2021
42a6f9d
Add more information to the program section of the storybook design
solid-maxim Jun 16, 2021
7f64e10
Fix diagram urls
solid-maxim Jun 16, 2021
0fb105b
Minor fix in diagram urls
solid-maxim Jun 16, 2021
fdf91e3
Minor fix in diagram urls
solid-maxim Jun 16, 2021
a67ccb0
Minor fix
solid-maxim Jun 16, 2021
0bd4540
Minor diagrams improvements
solid-tetianamovlian Jun 16, 2021
b6b8bf2
Add more diagrams to the storybook design
solid-maxim Jun 17, 2021
f704d0d
Resolve conflicts
solid-maxim Jun 17, 2021
cc4cce2
Improvements to the storybook docs
solid-maxim Jun 17, 2021
6d8b46e
Minor improvements
solid-maxim Jun 17, 2021
81b7664
Add more items to contents block
solid-maxim Jun 17, 2021
75354df
Minor improvements
solid-maxim Jun 17, 2021
6e3326d
Minor improvements
solid-tetianamovlian Jun 17, 2021
74355ec
Merge branch 'master' into metrics_storybook_design
solid-tetianamovlian Jun 17, 2021
32cce7f
Replace a storybook UI image with a salt diagram
solid-maxim Jun 22, 2021
f1b99fd
Improve the storybook design docs
solid-maxim Jun 22, 2021
9f8abac
Fix content section
solid-maxim Jun 22, 2021
216cfed
Fix diagram
solid-maxim Jun 22, 2021
10b7387
Minor improvements
solid-tetianamovlian Jun 23, 2021
cd926f5
Merge branch 'master' into metrics_storybook_design
solid-tetianamovlian Jun 23, 2021
7caefda
Fix diagram
solid-tetianamovlian Jun 23, 2021
ee0b355
Merge branch 'master' into metrics_storybook_design
solid-tetianamovlian Jun 25, 2021
5d129be
Review suggestions
solid-maxim Jun 29, 2021
2e475e0
Add widgets table. Fix adding new story
solid-tetianamovlian Jun 29, 2021
9fa393b
Minor widget's table improvements
solid-tetianamovlian Jun 29, 2021
d28c560
Update chapter and chapter controls methods and namings
solid-maxim Jun 29, 2021
4943cec
Minor sequence diagram fix
solid-tetianamovlian Jun 30, 2021
4a3cfe5
Add changing widget's appearance to sequence diagram
solid-tetianamovlian Jun 30, 2021
eb7a521
Minor fix
solid-tetianamovlian Jun 30, 2021
959a004
Minor fix
solid-tetianamovlian Jun 30, 2021
cea541e
Improve design document and fix diagrams
solid-maxim Jun 30, 2021
9069f98
Minor improvements
solid-tetianamovlian Jun 30, 2021
f4c2f82
Improve docs and diagrams
solid-maxim Jun 30, 2021
d2d9f4c
Minor fixes
solid-maxim Jun 30, 2021
d5de77f
Merge branch 'master' into metrics_storybook_design
solid-tetianamovlian Jun 30, 2021
d9cad8f
Review suggestions
solid-tetianamovlian Jul 6, 2021
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
Prev Previous commit
Next Next commit
Improve design document and fix diagrams
solid-maxim committed Jun 30, 2021
commit cea541e89baeac2da0734d6134dd369721b0bcd6
17 changes: 12 additions & 5 deletions metrics/web/docs/features/storybook/01_metrics_storybook_design.md
Original file line number Diff line number Diff line change
@@ -339,6 +339,9 @@ Consider the following structure of the `Metrics Storybook`:
> * `buttons/`
> * `chapters/`
> * `inactive_button_chapter.dart`
> * `controls/`
> * `buttons_chapter_control_name.dart`
> * `inactive_button_chapter_controls.dart`
> * `buttons_story.dart`
> * `...`
> * `chapter_controls.dart`
@@ -411,14 +414,18 @@ The `Story` is a class that groups together a list of `Chapter`s. The main purpo

The `Chapter` represents a specific widget we want to show in the storybook. The class contains a name of the specific chapter and a [ChapterControls](#chapter-controls). There is, also, the `build` method, which is responsible for building the widget, represented by the `Chapter` and applying the `ChapterControls`.

The `ChapterControls` class contains controls property, that UI widgets can use to build the [editing panel](#editing-panel) for the widget. The `controls` is a `Map` with the name of the control as a key, and a `ChapterControl` class as a value.
The `ChapterControls` is an abstract class that contains controls property, that UI widgets can use to build the [editing panel](#editing-panel) for the widget. The `controls` is a `Map` with the name of the control as a key, and a `ChapterControl` class as a value.

There is an `addControls` abstract method, that inherited classes should define to add different controls for the specific widget in one place.

The `ChapterControls` has several methods to add different `controls` to the chapter:

- ***textControl()*** - adds the `ChapterControl<String>` to the controls Map.
- ***boolControl()*** - adds the `ChapterControl<bool>` to the controls Map.
- ***colorControl()*** - adds the `ChapterControl<Color>` to the controls Map.
- ***numberControl()*** - adds the `ChapterControl<Number>` to the controls Map.
- ***addTextControl()*** - adds the `ChapterControl<String>` to the controls Map.
- ***addBoolControl()*** - adds the `ChapterControl<bool>` to the controls Map.
- ***addColorControl()*** - adds the `ChapterControl<Color>` to the controls Map.
- ***addNumberControl()*** - adds the `ChapterControl<Number>` to the controls Map.

And the `getControlValueByName()` to get the `ChapterControl` by related name.

The `ChapterControl` is deeply related to the `ChapterControls` and is used to build a single editing field for the storybook widget.

Original file line number Diff line number Diff line change
@@ -13,6 +13,12 @@ package widgets/theme {
}
}

package metrics/core/lib/src/domain/entities {
abstract class Enum<T> {
+ value : T
}
}

package storybook {
package state {
class ChaptersNotifier {
@@ -28,6 +34,32 @@ package storybook {
}

package stories {
package buttons {
package chapters {
class InactiveButtonChapter {
- _chapterControls : ChapterControls
+ name : String
+ controls : Map<String, ChapterControl>

+ build() : Widget
}
}
package controls {
class InactiveButtonChapterControls {
+ addControls() : void
}
class ButtonsChapterControlName {
+ {static} const label : ButtonsChapterControlName
+ {static} const values : Set<ButtonsChapterControlName>
+ toString() : String
}
}
class ButtonsStory {
+ name : String
+ chapters : List<Chapter>
}
}

abstract class Story {
+ name : String
+ chapters : List<Chapter>
@@ -43,10 +75,11 @@ package storybook {
class ChapterControls {
+ controls : Map<String, ChapterControl>

+ textControl(String name, String value) : String
+ boolControl(String name, bool value) : bool
+ colorControl(String name, Color value) : Color
+ numberControl(String name, Number value) : Number
+ addTextControl(String name, String value) : void
+ addBoolControl(String name, bool value) : void
+ addColorControl(String name, Color value) : void
+ addNumberControl(String name, Number value) : void
+ getControlValue(String name) : dynamic
}

class ChapterControl<T> {
@@ -91,25 +124,25 @@ package storybook {
}

class ChapterControlTextField {
+ property : ChapterControl<String>
+ property : ChapterControl<String>

+ build(BuildContext context) : Widget
}

class ChapterControlCheckboxField {
+ property : ChapterControl<Bool>
+ property : ChapterControl<Bool>

+ build(BuildContext context) : Widget
}

class ChapterControlColorField {
+ property : ChapterControl<Color>
+ property : ChapterControl<Color>

+ build(BuildContext context) : Widget
}

class ChapterControlSliderField {
+ property : ChapterControl<Number>
+ property : ChapterControl<Number>

+ build(BuildContext context) : Widget
}
@@ -124,11 +157,19 @@ Storybook -up-> Preview : creates
InjectionContainer -up-> StoriesNotifier : creates
InjectionContainer -up-> ChaptersNotifier : creates
InjectionContainer -up-> ThemeNotifier : creates
Storybook -down-> Story : uses
Storybook -down-> ButtonsStory : uses
Story -right-> Chapter : uses
Chapter -right-> ChapterControls : creates
ChapterControls -> ChapterControl : creates

ButtonsStory -down-|> Story : extends
ButtonsStory -> InactiveButtonChapter : creates
InactiveButtonChapter -down-|> Chapter : extends
InactiveButtonChapterControls -down-|> ChapterControls: extends
InactiveButtonChapter -right-> InactiveButtonChapterControls : creates
InactiveButtonChapterControls -right-> ButtonsChapterControlName : uses
ButtonsChapterControlName -right-|> Enum : extends

EditingPanel -up-> ChaptersNotifier : uses
Sidebar -up-> StoriesNotifier : uses
Preview -up-> ChaptersNotifier : uses
Original file line number Diff line number Diff line change
@@ -17,10 +17,11 @@ package storybook {
class ChapterControls {
+ controls : Map<String, ChapterControl>

+ textControl(String name, String value) : String
+ boolControl(String name, bool value) : bool
+ colorControl(String name, Color value) : Color
+ numberControl(String name, Number value) : Number
+ addTextControl(String name, String value) : void
+ addBoolControl(String name, bool value) : void
+ addColorControl(String name, Color value) : void
+ addNumberControl(String name, Number value) : void
+ getControlValue(String name) : dynamic
}

class ChapterControl<T> {