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

feat: add web component library with Stencil.js #92

Closed
wants to merge 6 commits into from

Conversation

Queentaker
Copy link

No description provided.

Copy link
Contributor

size-limit report 📦

Path Size
dist/index.cjs.production.min.js 79.89 KB (0%)
dist/index.esm.js 63.61 KB (0%)

@rschlaefli rschlaefli changed the title add: stencilJS Webcomponents feat: add web component library with Stencil.js Jun 28, 2024
@rschlaefli rschlaefli changed the base branch from main to V3 June 28, 2024 14:25
Copy link
Member

@rschlaefli rschlaefli left a comment

Choose a reason for hiding this comment

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

Really cool overall, made some comments for consistency and clarity :)

@@ -0,0 +1,3 @@
:host {
Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of the .css files as we do everything in Tailwind and as they contain just one and always the same display: block? E.g., can we move that single statement to Tailwind too?

Copy link
Member

Choose a reason for hiding this comment

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

maybe we can add the in React as a wrapper as done in some components? or is that for something else?

styleUrl: "tc-job-listing.css",
shadow: true,
})
export class JobListing {
Copy link
Member

Choose a reason for hiding this comment

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

We should make these names more generic. Is it really just a job listing or can it be used for any listing with an image and tags and a description?

Also, please remove the tc prefix from the file names :)

render() {
return (
<div
class={{
Copy link
Member

Choose a reason for hiding this comment

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

why are there sometimes classnames passed like this instead of as a string? -> use a single string for consistency

Copy link
Author

Choose a reason for hiding this comment

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

I think in this case here the class names should be passed normally. I think there are cases where this type of syntax makes sense
const textSection = ( <div class={{ "flex-1": true, "order-2": true, // Text always second on small screens "md:order-2": this.imageOnLeft, // Order on medium screens "md:order-1": !this.imageOnLeft, // Order on medium screens "px-4": true, "font-sans": true, "font-normal": true, }} >

TextSectionCode

Copy link
Member

@rschlaefli rschlaefli Jun 29, 2024

Choose a reason for hiding this comment

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

good point :) to get this kind of dynamic merging of classes depending on some props, use the https://www.npmjs.com/package/tailwind-merge utility (as shown in the readme there)

e.g., class={twMerge('flex-1 order-2 md:order-1 px-4 font-sans font-normal', this.imageOnLeft && 'md:order-2')}

so if this.imageOnLeft is true, md:order-2 will override md:order-1. if it is false, it will be ignored

export class TcGridContainer {
@Prop() mdColumns: number = 2;
@Prop() lgColumns: number = 4;
@Prop() columns: number = 1;
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@Prop() mdColumns: number = 2;
@Prop() lgColumns: number = 4;
@Prop() columns: number = 1;
@Prop() gap: string = "";
Copy link
Member

Choose a reason for hiding this comment

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

maybe like

Suggested change
@Prop() gap: string = "";
@Prop() gap: 'sm' | 'md' | 'lg' | 'xl' = "md";

using a default of md to cover the "default case" in the switch statement (so that default case could be removed now)

<h4 class="!m-0 text-xl md:text-3xl font-semibold">
{this.colTitle}
</h4>
<div class="mt-2 text-lg">{this.description}</div>
Copy link
Member

Choose a reason for hiding this comment

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

should we hide this if there is no description set? otherwise we have an empty space (mt-2)

})
export class ImgQuoteCard {
@Prop() quote: string;
@Prop() quotee: string;
Copy link
Member

Choose a reason for hiding this comment

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

some of the prop names are really hard to identify what it is used for. could you improve naming (does not matter if the prop names are a bit longer, quoteLabel or so?)

shadow: true,
})
export class SegmentContainer {
@Prop() segTitle: string;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Prop() segTitle: string;
@Prop() title: string;

the component is called SegmentContainer -> title would suffice to make it clear what it is

Copy link
Author

Choose a reason for hiding this comment

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

hab es geändert, nun kann man es aufrufen mit title
@prop({attribute:"title"}) segTitle: string;

Wieso?
title is a reserved name

Copy link
Member

@rschlaefli rschlaefli Jul 9, 2024

Choose a reason for hiding this comment

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

hoi @Queentaker, ich glaube, title ist ein html attribut für accessibility. dürftest du dann wohl nicht als prop name verwenden. sorry, das wusste ich nicht, dann müsste man es wohl segmentTitle nennen (dann ist der name auch klar)

@rschlaefli rschlaefli deleted the branch V3 August 8, 2024 09:29
@rschlaefli rschlaefli closed this Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants