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

fix: adding more notes #390

Draft
wants to merge 10 commits into
base: next
Choose a base branch
from
Draft

fix: adding more notes #390

wants to merge 10 commits into from

Conversation

glitchgirl
Copy link
Contributor

@glitchgirl glitchgirl commented May 17, 2023

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • [X ] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Visual Testing
  • Automated Testing
  • Accessibility Testing

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • Documentation
    • Introduced comprehensive documentation for component development, covering:
      • Additional resources and learning tools.
      • Coding guide and standards for building web components.
      • Component structure, composition, and extension.
      • Styling components, including guidance on CSS variables and Tailwind CSS.
      • Utilizing controllers within the Outline design system.
      • Explaining the render method and usage of partial templates.
      • Best practices for defining properties in components.
      • Using slots in web components.
      • Overview of component lifecycle methods.
      • Implementing event handlers for user interactions.
      • Utility functions for component development.
      • Extending components with Lit and Outline, including style and property overrides.

@changeset-bot
Copy link

changeset-bot bot commented May 17, 2023

⚠️ No Changeset found

Latest commit: fdfa9f4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented May 17, 2023

Deploy Preview for outlinejs ready!

Name Link
🔨 Latest commit fdfa9f4
🔍 Latest deploy log https://app.netlify.com/sites/outlinejs/deploys/65bbc334c826c000083529be
😎 Deploy Preview https://deploy-preview-390--outlinejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@glitchgirl glitchgirl marked this pull request as ready for review May 17, 2023 19:34
Copy link
Contributor

@himerus himerus left a comment

Choose a reason for hiding this comment

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

Minor adjustments.

### Slots versus properties
- When do I use a property?
- Properties are used for non-content features that impact the state of the component. For example, active versus inactive states.
- The component shouldn't change its own public properties, except in response to user input. For example, you could set a property to change background color, but the component itself shouldn't change it's own color.
Copy link

@mkochendorfer mkochendorfer May 18, 2023

Choose a reason for hiding this comment

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

I don't know that I agree with this statement entirely. I agree that the most common case for a component to update a reflected attribute would be based on some user action, but I think there are definitely cases where a component is doing something internally that warrants reflecting its internal state back in the HTML markup regardless of any user action.

Using the background color as an example, what if your component wants to go look up the browser configuration for dark mode and modify the background color that it uses in some way? Or override the default color with a user preference setting it pulls from an API endpoint?

A more realistic example would be timed carousel with a property the reflects the currently active slide index.

I feel like a better callout might be to only use reflect: true on a property when the component will actually modify that property internally, which is a pattern that many components in the repo are already failing to follow correctly, and this is a mistake I see made constantly by extension on my project:
https://github.com/search?q=repo%3Aphase2%2Foutline+%22reflect%3A+true%22&type=code

https://lit.dev/docs/components/properties/#reflected-attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this discussion

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this. A lot of the original components, IIRC had reflect: true on by default as "test mode", and it was argued that it was valuable to have that.

I agree it shouldn't be the default, but used when necessary and appropriate.

- When do I use a property?
- Properties are used for non-content features that impact the state of the component. For example, active versus inactive states.
- The component shouldn't change its own public properties, except in response to user input. For example, you could set a property to change background color, but the component itself shouldn't change it's own color.
- Slots are used for content, such as HTML markup, text, icons, or images.

Choose a reason for hiding this comment

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

Related to the above, I think this statement goes to far and also missed in my mind the actual primary use case for slots: flexible regions of a component

Icons in particular it really depends on whether the icons are built into the Outline package itself and thus are set using the name of the icon as a property on a component or if it is an svg upload that the content team does using any svg they wish.

Text often needs to be used as alt text or other things requiring attributes inside of the component, and thus cannot always use slots either.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps clarification can be given by some simple scenarios like:

For Example:

  • "if you were building Web Components to be consumed by a React App that does X, Y, and Z, you might do it this way.
  • "if you were building Web Components to be consumed by a Drupal App that does X, Y, and Z, you might do it this way.

I feel like that's probably where some of the assumptions are coming from. Our typical work still being Drupal, we need to account in our docs (and sample integrations would be nice) how to do things with different consumers.

- Properties are used for non-content features that impact the state of the component. For example, active versus inactive states.
- The component shouldn't change its own public properties, except in response to user input. For example, you could set a property to change background color, but the component itself shouldn't change it's own color.
- Slots are used for content, such as HTML markup, text, icons, or images.
- There are cases in which adding content as a property will make sense, for example using a title to control the state of the component. Use this cautiously, as it can cause issues with a11y tools and automation.
Copy link

@mkochendorfer mkochendorfer May 18, 2023

Choose a reason for hiding this comment

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

Do we have specific examples of how this can go wrong with a11y tools? My understanding has been that that was really just a lag in the a11y tools support for web components/shadow dom, which is quickly being addressed as web component usage is exploding across the web with increased browser support.

Copy link
Contributor

Choose a reason for hiding this comment

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

Use this cautiously, as it can cause issues with a11y tools and automation.

I think this relates to how some tools still are unable to pierce the Shadow DOM for inspecting things and may fail a11y tests if we, say build the h1 tag inside the ShadowDOM, but the tool doesn't read it as such.

@glitchgirl correct me if I'm wrong there in your thinking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is exactly correct

Copy link

coderabbitai bot commented Feb 1, 2024

Walkthrough

The recent update introduces comprehensive documentation and guidelines for component development within the Outline framework and Lit2. It covers a wide range of topics from the basic structure and styles of components, to more advanced concepts such as lifecycle methods, properties, slots, and event handling. Additionally, it provides resources on extending components and utility functions, alongside a file dedicated to additional resources and tools for web development.

Changes

File Path Change Summary
.../99-additional-resources.mdx New documentation on additional resources for component development.
.../component-development/main.mdx Introduction to component development with coding guide and standards.
.../component-development/01-component-structure.mdx Guidelines on component composition and structure.
.../component-development/03-styles.mdx Guidance on styling components, including CSS variables and Tailwind CSS.
.../component-development/04-controllers.mdx, .../component-development/08-lifecycle-methods.mdx Documentation focusing on controllers and lifecycle methods in component development.
.../component-development/05-render.mdx, .../component-development/07-slots.mdx Documentation and examples for the render method and using slots in components.
.../component-development/06-properties.mdx, .../component-development/09-events.mdx, .../component-development/10-utility-functions.mdx, .../component-development/11-extending.mdx Documentation on properties, event handlers, utility functions, and extending components.

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a37a2af and fdfa9f4.
Files selected for processing (12)
  • packages/outline-docs/src/guides/99-additional-resources.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/01-component-structure.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/03-styles.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/04-controllers.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/05-render.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/06-properties.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/07-slots.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/08-lifecycle-methods.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/09-events.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/10-utility-functions.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/11-extending.mdx (1 hunks)
  • packages/outline-docs/src/guides/component-development/main.mdx (1 hunks)

Comment on lines +33 to +36
```typescript
private utilityFunction = (data: string[]) => {
data.forEach(str: string=> console.log(str))
}
Copy link

Choose a reason for hiding this comment

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

Syntax error in the TypeScript code block.

-  data.forEach(str: string=> console.log(str)) 
+  data.forEach((str: string) => console.log(str)); 

The arrow function syntax is incorrect. It should have parentheses around the parameter and a semicolon at the end of the statement.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
```typescript
private utilityFunction = (data: string[]) => {
data.forEach(str: string=> console.log(str))
}
private utilityFunction = (data: string[]) => {
data.forEach((str: string) => console.log(str));
}

@glitchgirl glitchgirl changed the base branch from next to feature/outline-core-link-updates February 6, 2024 14:57
@himerus himerus marked this pull request as draft February 6, 2024 17:26
@himerus
Copy link
Contributor

himerus commented Feb 6, 2024

Marking this as Draft, as the system is thinking these are all new files, not to be merged with the updates I had made and moving things around, etc.

@himerus himerus added CANNOT MERGE Temporary flag for a PR that has failing tests, broken pipelines, etc. Held for Review Held for review. Considered as a Draft/POC. labels Feb 6, 2024
Base automatically changed from feature/outline-core-link-updates to next February 15, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CANNOT MERGE Temporary flag for a PR that has failing tests, broken pipelines, etc. Documentation Held for Review Held for review. Considered as a Draft/POC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants