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

Readonly boolean 2 #2853

Merged
merged 13 commits into from
Mar 27, 2024
Merged

Readonly boolean 2 #2853

merged 13 commits into from
Mar 27, 2024

Conversation

jgroth
Copy link
Contributor

@jgroth jgroth commented Mar 19, 2024

Suggestions for improvements for #2747

  • The private component is public, renamed to limel-label to make it reusable in other scenarios
  • Changed the interface of the component, can now take other values and not only booleans
  • Changed the interface of the ReadonlyProps, the Label interface now represents a single label with a value, text and icon

Copy link

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-2853/

@@ -1,4 +1,4 @@
:host(limel-example-readonly-boolean) {
:host(limel-example-label) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should also remember to reword the commit title

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything is fixups to your commits and targets your branch 😄

Comment on lines +47 to +51
readonlyLabels={[
{
value: true,
icon: 'news',
text: 'Is subscribed to receive newsletters',
Copy link
Contributor

@Kiarokh Kiarokh Mar 26, 2024

Choose a reason for hiding this comment

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

🤔 these don't seem to work for true, the default ones are being used

Screenshot 2024-03-26 at 11 27 21

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +44 to +56
readonlyLabels={[
{
value: true,
icon: 'news',
text: 'Is subscribed to receive newsletters',
},
{
value: false,
icon: {
name: 'cancel_subscription',
color: 'rgb(var(--color-orange-default))',
},
text: 'Is unsubscribed from newsletters',
Copy link
Contributor

Choose a reason for hiding this comment

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

Screen.Recording.2024-03-26.at.11.55.03.mov

these seem to work in a weird way for limel-switch. You have to toggle the selected state for them to work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@Kiarokh Kiarokh Mar 26, 2024

Choose a reason for hiding this comment

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

Screen.Recording.2024-03-26.at.11.57.24.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* @beta
*/
@Component({
tag: 'limel-label',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tag: 'limel-label',
tag: 'limel-dynamic-label',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 8 to 9
* value. A label can consist of a text and an icon. If no matching label is
* found, the default label will be displayed.
Copy link
Contributor

Choose a reason for hiding this comment

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

To me this description is unclear:

If no matching label is found, the default label will be displayed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 28 to 47
/**
* The value of the component.
*
* The value will be matched with the given labels to determine what label
* to display
*/
@Prop({ reflect: true })
public value: LabelValue;

/**
* Default label to display if no label with corresponding value is found
*/
@Prop({ reflect: true })
public defaultLabel: Omit<Label, 'value'> = {};

/**
* Available labels
*/
@Prop()
public labels: Label[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't say that I read these docs and understand what these props do 😅
Even when I look at the code, I am still confused. But the consumer only sees the props' description in the generated docs. So the docs should make it clear what these props do.

I tried to improve the docs like below:

Suggested change
/**
* The value of the component.
*
* The value will be matched with the given labels to determine what label
* to display
*/
@Prop({ reflect: true })
public value: LabelValue;
/**
* Default label to display if no label with corresponding value is found
*/
@Prop({ reflect: true })
public defaultLabel: Omit<Label, 'value'> = {};
/**
* Available labels
*/
@Prop()
public labels: Label[] = [];
/**
* The current value of the component;
* which is used to match with the `labels` array to determine the label to display.
* If no matching label is found, the `defaultLabel` is displayed.
*/
@Prop({ reflect: true })
public value: LabelValue;
/**
* The label to display when no matching value is found in the `labels` array.
* This is a fallback label that ensures there's always a label displayed for the component.
*/
@Prop({ reflect: true })
public defaultLabel: Omit<Label, 'value'> = {};
/**
* An array of available labels. Each label in this array has a corresponding value.
* When the `value` prop matches a value in this array, the corresponding label is displayed.
*/
@Prop()
public labels: Label[] = [];

However, I am still unsatisfied and confused 😕 .

What if we rename the component to limel-dynamic-label and then we can rename the props like these:

Suggested change
/**
* The value of the component.
*
* The value will be matched with the given labels to determine what label
* to display
*/
@Prop({ reflect: true })
public value: LabelValue;
/**
* Default label to display if no label with corresponding value is found
*/
@Prop({ reflect: true })
public defaultLabel: Omit<Label, 'value'> = {};
/**
* Available labels
*/
@Prop()
public labels: Label[] = [];
/**
* The current value of the component;
* which is used to match with the `dynamicLabels` array to determine the label to display.
* If no matching label is found, the `label` is displayed.
*/
@Prop({ reflect: true })
public value: LabelValue;
/**
* The label to display when no matching value is found in the `dynamicLabels` array.
* This is a fallback label that ensures there's always a label displayed for the component.
*/
@Prop({ reflect: true })
public label: Omit<Label, 'value'> = {};
/**
* An array of available labels which can be dynamically applied based on the given value.
* Each label in this array will have to have a corresponding value.
* When the `value` prop matches a value in this array,
* the corresponding label is dynamically displayed.
*/
@Prop()
public dynamicLabels: Label[] = [];

A bit better. But what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the descriptions but did not change the names

bc895e2

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK if you wanna squash all these and merge them into my branch. I think we can continue from there more easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't squash them here easily, lets just merge it to the other branch first

Copy link
Contributor

Choose a reason for hiding this comment

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

sure. I just mean things are OK from my perspective

@jgroth jgroth marked this pull request as ready for review March 26, 2024 13:59
@jgroth jgroth merged commit d824379 into readonly-boolean Mar 27, 2024
8 of 11 checks passed
@jgroth jgroth deleted the readonly-boolean-2 branch March 27, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants