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

[KOptionalText] New component #403

Merged
merged 6 commits into from
Feb 7, 2023

Conversation

AlexVelezLl
Copy link
Member

@AlexVelezLl AlexVelezLl commented Dec 17, 2022

Description

Add a new component to KDS KOptionalText that will either display the text or KEmptyPlacehlder if it's an empty string, undefined, or null.

Issue addressed

Addresses #285

Steps to test

  1. Link this KDS branch to any product.
  2. Use KOptionalText component as described in Implementation notes.

Implementation notes

At a high level, how did you implement this?

KOptionalText will recieve a text prop or slot that renders text nodes, if there is text to show, the text or the slot will be shown whithin a span element, if not, the KEmptyPlacehlder component will be shown. Also a textStyle prop can be passed which will be set to the span element.

Examples:

All of them will render "Hello world" in red color:

<KOptionalText text="Hello world" appearanceOverrides="color: red" />

<KOptionalText appearanceOverrides="color: red">
  Hello World
<KOptionalText/>

<KOptionalText>
  <span style="color: red">Hello </span>
  <span style="color: red">World</span>
</KOptionalText>

If name and lastname are nonempty strings name and lastname will be shown. If not it will render a "-":

<KOptionalText :text="`${name} ${lastname}`" />

<KOptionalText>
  <span>{{ name }}</span>
  <span>{{ lastname }}</span>
</KOptionalText>

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical and brittle code paths are covered by unit tests
  • The change has been added to the changelog

Reviewer guidance

  • Is the code clean and well-commented?
  • Are there tests for this change?
  • Are all UI components LTR and RTL compliant (if applicable)?

@AlexVelezLl AlexVelezLl force-pushed the add-koptionaltext branch 2 times, most recently from 3781c25 to f67f756 Compare December 17, 2022 22:35
@AlexVelezLl AlexVelezLl added the TODO: needs review Waiting for review label Dec 19, 2022
@marcellamaki marcellamaki requested a review from akolson January 9, 2023 13:25
Copy link
Member

@akolson akolson left a comment

Choose a reason for hiding this comment

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

Hi @AlexVelezLl code generally LGTM! Please see herein a few recommendation

@AlexVelezLl
Copy link
Member Author

Hi @akolson! Thank you for the recommendations! I have updated the branch with them :)

Copy link
Member

@akolson akolson left a comment

Choose a reason for hiding this comment

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

Thanks @AlexVelezLl for the changes. LGTM!
Once the accompanying PR in Kolibri/Studio(if any) has been tested for functionality of the component, this PR should be merged! cc @marcellamaki

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

I think it would be good to add this new component to the documentation, especially as you have already written out examples. See here on how to do this: https://github.com/learningequality/kolibri-design-system#development-of-the-documentation-site

The other slight concern is that the Kolibri frontend tests for this integration are failing - showing empty string instead of the placeholder text. Possible that this is a result of stubbing of child components, but would be good to verify what is happening there.

@AlexVelezLl
Copy link
Member Author

Hi @rtibbles! tests on Kolibri were fixed, and docs for this component were added! Let me know if everything is ok with the wording of the docs. Once this PR is merged, I can proceed with updating learningequality/kolibri#10050 to bring the reference back to the main KDS branch.

</tbody>
</table>
</DocsShow>
</DocsPageSection>
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a second example showing how it works with the default slot as well?

Copy link
Member Author

@AlexVelezLl AlexVelezLl Feb 7, 2023

Choose a reason for hiding this comment

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

Sure! Could it be a new row on the current example table? Or should it be a new different example?

Copy link
Member

Choose a reason for hiding this comment

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

I think maybe do it as a separate example, and then you can add some explanatory text about how it is different to the example above. Can even show the difference in a codeblock like you did in your PR description. For an example of showing code instead of rendering the code, see here: https://github.com/learningequality/kolibri-design-system/blob/develop/docs/pages/kcheckbox.vue#L67

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it! I have added one more example, with code examples 😃

@rtibbles rtibbles merged commit 6bae827 into learningequality:develop Feb 7, 2023
@AlexVelezLl AlexVelezLl deleted the add-koptionaltext branch February 21, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants