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

Refactor card widgets to use a shared base component (oh-card) #2781

Merged
merged 13 commits into from
Oct 1, 2024

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Oct 1, 2024

Supersedes #1801.

Implements the great proposal from #1801 (comment):

There is currently no generic oh-card, the oh-*-card widget simply use f7-card in their implementation. A oh-card that would serve as a base for other card widgets would be nice as it could define a common set of properties that the card itself (as opposed to the widget inside its content) supports - and style and class would be one of them, other renamed style/class properties would be defined for the control inside the card. This oh-card could also define slots (which the f7-card doesn't do) - header, content and footer - and for instance the oh-rollershutter-card would simply have to define the content slot. The user would then be able to define the other slots (header and footer) to customize them beyond a simple text.

Lastly a oh-card could be useful even when designing a custom card as it would simplify the syntax. For example:

component: f7-card
config:
  style: {} # Card style
  class: [] # Card classes
slots:
  default:
    - component: f7-card-header
      config:
        style: {} # Header style
        class: [] # Header classes
      slots:
        default:
          - component: oh-button
            config:
              text: Header
    - component: f7-card-content
      config:
        style: {} # Content style
        class: [] # Content classes
      slots:
        default:
          - component: oh-button
            config:
              text: Content
    - component: f7-card-footer
      config:
        style: {} # Footer style
        class: [] # Footer classes
      slots:
        default:
          - component: oh-button
            config:
              text: Footer

would become:

component: oh-card
style:
  style: {} # Card style
  class: [] # Card classes
  headerStyle: {} # Header style
  headerClass: [] # Header classes
  contentStyle: {} # Content style
  contentClass: [] # Content classes
  footerStyle: {} # Footer style
  footerClass: [] # Footer classes
slots:
  header:
    - component: oh-button
       config:
         text: Header
  content:
    - component: oh-button
       config:
         text: Content
  footer:
    - component: oh-button
       config:
         text: Footer

If the header, content, footer slot contains resp. f7-card-header, f7-card-content or f7-card-footer as the only component they would be inserted directly as defined, otherwise those would be created automatically. oh-card-footer could be made obsolete as its functionality could be integrated into oh-card.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Copy link

relativeci bot commented Oct 1, 2024

#2312 Bundle Size — 10.83MiB (+0.01%).

437540a(current) vs 4785cfa main#2306(baseline)

Warning

Bundle contains 2 duplicate packages – View duplicate packages

Bundle metrics  Change 4 changes Regression 1 regression Improvement 1 improvement
                 Current
#2312
     Baseline
#2306
Regression  Initial JS 1.89MiB(+0.09%) 1.89MiB
Improvement  Initial CSS 576.57KiB(-0.01%) 576.65KiB
Change  Cache Invalidation 24.05% 17.44%
No change  Chunks 226 226
No change  Assets 249 249
Change  Modules 2917(-0.14%) 2921
No change  Duplicate Modules 149 149
No change  Duplicate Code 1.8% 1.8%
No change  Packages 96 96
No change  Duplicate Packages 2 2
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#2312
     Baseline
#2306
Regression  JS 9.04MiB (+0.02%) 9.04MiB
Improvement  CSS 863.34KiB (~-0.01%) 863.42KiB
No change  Fonts 526.1KiB 526.1KiB
No change  Media 295.6KiB 295.6KiB
No change  IMG 140.74KiB 140.74KiB
No change  HTML 1.39KiB 1.39KiB
No change  Other 871B 871B

Bundle analysis reportBranch florian-h05:refactor-oh-cardProject dashboard


Generated by RelativeCIDocumentationReport issue

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 added this to the 4.3 milestone Oct 1, 2024
@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Oct 1, 2024
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05
Copy link
Contributor Author

As I have now tested all card widgets, I will merge this PR.

@florian-h05 florian-h05 marked this pull request as ready for review October 1, 2024 15:40
@florian-h05 florian-h05 requested a review from ghys as a code owner October 1, 2024 15:40
@florian-h05 florian-h05 merged commit dcbc549 into openhab:main Oct 1, 2024
8 checks passed
@florian-h05 florian-h05 deleted the refactor-oh-card branch October 1, 2024 15:45
@florian-h05 florian-h05 changed the title Refactor card widgets to use a shared base component Refactor card widgets to use a new, shared base component Oct 1, 2024
@florian-h05 florian-h05 changed the title Refactor card widgets to use a new, shared base component Refactor card widgets to use a shared base component (oh-card) Oct 1, 2024
@stefan-hoehn
Copy link
Contributor

Thanks for the awesome job! <3 Great improvement for styling!

@florian-h05
Copy link
Contributor Author

FYI @JustinGeorgi @rkoshak

@ghys
Copy link
Member

ghys commented Oct 1, 2024

Awesome!

florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Oct 3, 2024
Fixes openhab#2793.
Regression from openhab#2781.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit that referenced this pull request Oct 3, 2024
Fixes #2793.
Regression from #2781.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit to florian-h05/openhab-webui that referenced this pull request Oct 3, 2024
Regression from openhab#2781.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit that referenced this pull request Oct 3, 2024
Regression from #2781.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
stefan-hoehn pushed a commit to stefan-hoehn/openhab-webui that referenced this pull request Oct 5, 2024
)

Fixes openhab#2793.
Regression from openhab#2781.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
stefan-hoehn pushed a commit to stefan-hoehn/openhab-webui that referenced this pull request Oct 5, 2024
Regression from openhab#2781.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
florian-h05 added a commit that referenced this pull request Dec 19, 2024
Regression from #2781.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
florian-h05 added a commit that referenced this pull request Dec 19, 2024
Regression from #2781.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
(cherry picked from commit a907cc3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants