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
Show file tree
Hide file tree
Changes from 36 commits
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
359 changes: 359 additions & 0 deletions metrics/web/docs/features/storybook/01_metrics_storybook_design.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@startuml metrics_storybook_architecture_components_diagram
solid-maxim marked this conversation as resolved.
Show resolved Hide resolved

skinparam componentStyle rectangle

component "Metrics Storybook" as MS

component "Story (e.g., Buttons)" as ButtonsStory
component "Chapter (e.g., Positive Button)" as PositiveButtonChapter

component "Story (e.g., Toasts)" as ToastsStory
component "Chapter (e.g., Positive Toast)" as PositiveToastChapter
component "Chapter Controls" as PositiveToastChapterControls
component "Text Control (e.g., text input)" as FirstPositiveToastChapterTextControl
component "Bool Control (e.g., checkbox)" as SecondPositiveToastChapterBoolControl
component "Chapter (e.g., Negative Toast)" as NegativeToastChapter
component "Chapter Controls" as NegativeToastChapterControls
component "Text Control (e.g., text input)" as FirstNegativeToastChapterTextControl
component "Bool Control (e.g., checkbox)" as SecondNegativeToastChapterBoolControl

MS -down-> ButtonsStory
MS -down-> ToastsStory

ButtonsStory -down-> PositiveButtonChapter

ToastsStory -down-> PositiveToastChapter
PositiveToastChapter -down-> PositiveToastChapterControls
PositiveToastChapterControls -down-> FirstPositiveToastChapterTextControl
PositiveToastChapterControls -down-> SecondPositiveToastChapterBoolControl

ToastsStory -down-> NegativeToastChapter
NegativeToastChapter -down-> NegativeToastChapterControls
NegativeToastChapterControls -down-> FirstNegativeToastChapterTextControl
NegativeToastChapterControls -down-> SecondNegativeToastChapterBoolControl

@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
@startuml metrics_storybook_class_diagram

package widgets/theme {
class ThemeNotifier {
- _selectedTheme : ThemeType
+ isDark : bool
+ selectedTheme : ThemeType
solid-maxim marked this conversation as resolved.
Show resolved Hide resolved

+ changeTheme(ThemeType themeType) : void
+ toggleTheme() : void
+ setTheme(Brightness brightness) : void
- _isBrightnessDark(Brightness brightness) : bool
}
}

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

package storybook {
package state {
class ChaptersNotifier {
+ currentChapter : Chapter

+ selectChapter(Chapter chapter) : void
+ refreshChapter() : void
}

class StoriesNotifier {
+ stories : List<Story>
}
}

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

+ build() : Widget
}
}
package controls {
class InactiveButtonChapterControls {
- {static} _controls : Map<String, ChapterControl>

+ controls : Map<String, ChapterControl>
}
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>
}

abstract class Chapter {
+ name : String
+ controls : ChapterControls

+ build() : Widget
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📱
What do you think about splitting the data model and the view into different classes? I believe it would be great to have a widget and a Chapter model for each Metrics widget. Also, I believe it would be cleaner and more structured if we'll have view models for each Metrics widget and for each widget representing a ChapterControl so that we'll have a ChangeNotifier containing a list of Stories and a selected Chapter. Also, we'll have a ChangeNotifier that will hold and control the ChapterControls for the selected Chapter and provide a view model used to build it.


abstract class ChapterControls {
- _controls : Map<String, ChapterControl>
+ controls : Map<String, ChapterControl>

+ getControlValue(String name) : dynamic
}

class ChapterControl<T> {
+ name : String
+ value : T
}
}

package mappers {
class ChapterControlMapper {
+ map(ChapterControl<T> control) : Widget
}
}

package widgets {
class Storybook {
+ stories : List<Story>
}

class InjectionContainer {
+ stories : List<Story>
}

class Sidebar {
+ build(BuildContext context) : Widget
}

class Preview {
+ build(BuildContext context) : Widget
}

class EditingPanel {
- _widgets : List<Widget>

+ build(BuildContext context) : Widget
}

package control_fields {
class ChapterControlField {
+ label : String
+ child : Widget
}

class ChapterControlTextField {
+ property : ChapterControl<String>

+ build(BuildContext context) : Widget
}

class ChapterControlCheckboxField {
+ property : ChapterControl<Bool>

+ build(BuildContext context) : Widget
}

class ChapterControlColorField {
+ property : ChapterControl<Color>

+ build(BuildContext context) : Widget
}

class ChapterControlSliderField {
+ property : ChapterControl<Number>

+ build(BuildContext context) : Widget
}
}
}
}

Storybook -up-> InjectionContainer : creates and provides a list of stories
Storybook -up-> EditingPanel : creates
Storybook -up-> Sidebar : creates
Storybook -up-> Preview : creates
InjectionContainer -up-> StoriesNotifier : creates
InjectionContainer -up-> ChaptersNotifier : creates
InjectionContainer -up-> ThemeNotifier : creates
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
EditingPanel -up-> ChapterControlMapper : uses
ChapterControlField -> ChaptersNotifier : uses

ChapterControlMapper -> ChapterControlTextField : uses
ChapterControlMapper -> ChapterControlCheckboxField : uses
ChapterControlMapper -> ChapterControlColorField : uses
ChapterControlMapper -> ChapterControlSliderField : uses

ChapterControlTextField -down-> ChapterControlField : uses
ChapterControlCheckboxField -down-> ChapterControlField : uses
ChapterControlColorField -down-> ChapterControlField : uses
ChapterControlSliderField -down-> ChapterControlField : uses

@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@startuml metrics_storybook_sequence_diagram

skinparam ParticipantPadding 20
skinparam BoxPadding 10

actor Bob

box "Metrics Storybook"
participant UI
participant Storybook << (W,#ADD1B2) >>
participant InjectionContainer << (C,#ADD1B2) >>
participant StoriesNotifier << (C,#ADD1B2) >>
participant ChaptersNotifier << (C,#ADD1B2) >>
participant ThemeNotifier << (C,#ADD1B2) >>
participant Sidebar << (W,#ADD1B2) >>
participant Preview << (W,#ADD1B2) >>
participant "Editing Panel" as EP << (W,#ADD1B2) >>
participant ChapterControls << (W,#ADD1B2) >>
end box

Bob -> UI : enters the application
UI -> Storybook : creates stories (with chapters)
Storybook -> InjectionContainer : provides stories
InjectionContainer -> StoriesNotifier : registers and provides stories
InjectionContainer -> ChaptersNotifier : registers
StoriesNotifier -> Sidebar : provides stories
Sidebar -> UI : displays a list of stories and chapters
UI -> Bob : shows a UI with a list of storybook widgets

alt Bob clicks on the chapter (widget) in the Sidebar:
Bob -> UI : clicks on the menu item in the sidebar
UI -> ChaptersNotifier : selects a chapter
ChaptersNotifier -> Preview : provides a chapter
ChaptersNotifier -> EP : provides a chapter
EP -> ChapterControls : gets a chapter's controls
Preview -> UI : displays a selected chapter
EP -> UI : displays list of controls to change a chapter's appearance
UI -> Bob : shows a UI with the selected widget\n and a list of controls to change a chapter's appearance
end

alt Bob changes a chapter's appearance using control:
Bob -> EP : changes a chapter's control value
EP -> ChaptersNotifier : refreshes a chapter
ChaptersNotifier -> Preview : notifies about changing chapter's appearance
Preview -> UI : displays changed chapter
UI -> Bob : shows a UI with the changed widget
end

alt Bob clicks the toggle theme button:
Bob -> UI : clicks the toggle theme button
UI -> ThemeNotifier : toggle theme
ThemeNotifier -> UI : notifies about theme changes
UI -> Bob : shows UI in the toggled theme
end

@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@startuml metrics_storybook_class_diagram

package storybook {
package stories {
abstract class Story {
+ name : String
+ chapters : List<Chapter>
}

abstract class Chapter {
+ name : String
+ controls : ChapterControls

+ build() : Widget
}

abstract class ChapterControls {
- _controls : Map<String, ChapterControl>
+ controls : Map<String, ChapterControl>

+ getControlValue(String name) : dynamic
solid-maxim marked this conversation as resolved.
Show resolved Hide resolved
}

class ChapterControl<T> {
+ name : String
+ value : T
}
}
}

Story -right-> Chapter : uses
Chapter -right-> ChapterControls : creates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:readable:
Would it be great to explain the way of creation of the ChapterControls?

ChapterControls -> ChapterControl : creates

@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@startsalt metrics_storybook_user_interface_diagram
{#
{-
Metrics Storybook
{!
{T
+
+Metrics Logo <&image>
+
+ Buttons
++ <color:green>Inactive Button
++ Neutral Button
++ Positive Button
+ Toasts
++ Negative Graph Indicator
++ Positive Graph Indicator
+ Graph Indicators
++ Inactive Graph Indicator
++ Neutral Graph Indicator
++ Positive Graph Indicator
+
+
+
+
+
<color:red>Sidebar
} | {-
<color:red>Toggle theme button <&sun>
{!
{
.
.
.
.
[Inactive button]
.
.
.
.
.
.
.
.
.
.
<color:red>Preview field
} | {
.
.
.
.
Label
"Inactive Button "
.
.
.
.
.
.
.
.
.
<color:red>Editing panel
}
}
}
}
}
}
@endsalt
Loading