writer / writer-framework

No-code in the front, Python in the back. An open-source framework for creating data apps.
https://dev.writer.com/framework/introduction
Apache License 2.0
1.3k stars 73 forks source link

fix: Hide `CoreText` in preview if empty value. WF-20 #482

Closed madeindjs closed 1 month ago

madeindjs commented 2 months ago

Simply hide the CoreText using v-if in preview mode if the value is emptyText. We still display the component in edit mode.

Screencast from 2024-06-29 14-37-01.webm

FabienArcellier commented 1 month ago

We discuss about generalizing the way we manage this sort of state. We will try to use EmptinessLabel to encapsulate the behavior.

We would work with this layout

image

madeindjs commented 1 month ago

Hello @FabienArcellier & @ramedina86 ,

I'm trying to implement a general behavior to handle empty state for CoreText & CoreMessage . As @FabienArcellier pointed, we might want to have a general way to do this.

I succeded to implement a EmptinessState component who does the job (https://github.com/writer/writer-framework/pull/482/commits/5ef475be9fd4be7a72d79fc6e063005a22ac0606) but it takes some space in preview mode (as we still render an empty comp).

Screencast from 2024-07-16 00-24-36.webm

I saw empty state of sidebar / Header / etc.. use a different logic. It uses ChildlessPlaceholder through ComponentProxy.

https://github.com/writer/writer-framework/blob/df6fa8d260ef8fd8cc8a50173b36e6943950ae43/ui/src/renderer/ComponentProxy.vue#L37-L42

So I wonder if we want the same mechanism or if it's a bit overkill for the need and the v-if is enough (https://github.com/writer/writer-framework/pull/482/commits/ba05e5045367a18b69ba6b10f82df38438dd6af3)

WDTY?

FabienArcellier commented 1 month ago

Hello @FabienArcellier & @ramedina86 ,

I'm trying to implement a general behavior to handle empty state for CoreText & CoreMessage . As @FabienArcellier pointed, we might want to have a general way to do this.

I succeded to implement a EmptinessState component who does the job (5ef475b) but it takes some space in preview mode (as we still render an empty comp).

Screencast.from.2024-07-16.00-24-36.webm I saw empty state of sidebar / Header / etc.. use a different logic. It uses ChildlessPlaceholder through ComponentProxy.

https://github.com/writer/writer-framework/blob/df6fa8d260ef8fd8cc8a50173b36e6943950ae43/ui/src/renderer/ComponentProxy.vue#L37-L42

So I wonder if we want the same mechanism or if it's a bit overkill for the need and the v-if is enough (ba05e50)

WDTY?

For the empty state of sidebar / Header / etc, I would stick to the current logic. The v-if looks fine.

ramedina86 commented 1 month ago

@madeindjs Those are two different things

Childless placeholder: Automatically applied to any component that can contain children but doesn't

The other one (what you've called EmptinessState) should be used for when rendering the component would yield undesirable results due to lack of configuration/content.