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

Beta tech debt #72

Merged
merged 6 commits into from
Oct 1, 2024
Merged

Beta tech debt #72

merged 6 commits into from
Oct 1, 2024

Conversation

jordanjones243
Copy link
Contributor

@jordanjones243 jordanjones243 commented Oct 1, 2024

Alaska Airlines Pull Request

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.

Resolves: #64, #70

Summary:

Please summarize the scope of the changes you have submitted, what the intent of the work is and anything that describes the before/after state of the project.

Type of change:

Please delete options that are not relevant.

  • New capability
  • Revision of an existing capability
  • Infrastructure change (automation, etc.)
  • Other (please elaborate)

Checklist:

  • My update follows the CONTRIBUTING guidelines of this project
  • I have performed a self-review of my own update

By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Pull Requests will be evaluated by their quality of update and whether it is consistent with the goals and values of this project. Any submission is to be considered a conversation between the submitter and the maintainers of this project and may require changes to your submission.

Thank you for your submission!

-- Auro Design System Team

Summary by Sourcery

Refactor the auro-card component to enhance version control and flexibility by introducing a method for registering custom components with unique names. Update documentation and tests to reflect these changes, and remove deprecated Husky hook lines. Additionally, update design tokens and web core stylesheets to newer versions.

New Features:

  • Introduce a new method to register custom components with unique names to prevent versioning conflicts.

Enhancements:

  • Refactor the auro-card component to use a dynamic tag for auro-hyperlink, allowing for better version control and flexibility.
  • Update the auro-card component to handle component tag renaming for better integration and customization.

Documentation:

  • Add documentation on recommended use and version control for Auro components, including examples of custom element registration.

Tests:

  • Update tests to verify the rendering of auro-hyperlink using dynamic tags instead of static element names.

Chores:

  • Remove deprecated Husky hook lines to prepare for future updates.
  • Update design tokens and web core stylesheets to newer versions in the README.

@jordanjones243 jordanjones243 self-assigned this Oct 1, 2024
@jordanjones243 jordanjones243 requested a review from a team as a code owner October 1, 2024 22:12
Copy link

sourcery-ai bot commented Oct 1, 2024

Reviewer's Guide by Sourcery

This pull request focuses on updating the auro-card component to improve version control, enhance compatibility, and refactor some of the code. The changes include introducing a new method for registering components, updating dependencies, and making adjustments to improve the component's flexibility and performance.

Sequence diagram for component registration process

sequenceDiagram
    participant Developer
    participant RuntimeUtils
    participant AuroCard
    Developer->>RuntimeUtils: import { AuroCard }
    Developer->>RuntimeUtils: registerComponent('custom-card', AuroCard)
    RuntimeUtils->>AuroCard: Define custom element
    AuroCard-->>RuntimeUtils: Custom element defined
    RuntimeUtils-->>Developer: Custom element ready for use
Loading

Class diagram for updated AuroCard component

classDiagram
    class AuroCard {
        +LitElement
        +role: article
        +runtimeUtils: AuroLibraryRuntimeUtils
        +hyperlinkTag: String
        +firstUpdated()
        +render() HTML
    }
    class AuroLibraryRuntimeUtils
    class AuroDependencyVersioning {
        +generateTag(componentName, version, component)
    }
    AuroCard --> AuroLibraryRuntimeUtils
    AuroCard --> AuroDependencyVersioning
    AuroCard --> AuroHyperlink
    AuroDependencyVersioning --> AuroHyperlink
Loading

File-Level Changes

Change Details Files
Introduced a new method for registering components to prevent versioning conflicts
  • Added a new registerComponent method using RuntimeUtils
  • Updated the usage of registerComponent in index.js and demo/index.html
  • Added documentation for the new registration method in demo/index.md
index.js
demo/index.html
demo/index.md
Updated dependencies and removed explicit versions from HTML files
  • Updated design-tokens and webcorestylesheets versions in README.md
  • Removed explicit version for auro-hyperlink in demo/index.html and demo/api.html
README.md
demo/index.html
demo/api.html
Refactored auro-card component to use dynamic tag names for better compatibility
  • Added runtimeUtils and versioning to the component
  • Updated the render method to use dynamic tag names
  • Modified CSS selectors to target attributes instead of element names
src/auro-card.js
src/style.scss
src/color.scss
Added new files for improved development and documentation
  • Created eslint.config.mjs for ESLint configuration
  • Added apiExamples/custom.html for API documentation
  • Created src/hyperlinkVersion.js to manage hyperlink version
eslint.config.mjs
apiExamples/custom.html
src/hyperlinkVersion.js
Removed color definitions from GitHub labels in settings.yml
  • Removed color definitions for various labels
.github/settings.yml
Updated test files to accommodate changes in component structure
  • Modified selectors in tests to use attributes instead of element names
test/auro-card.test.js
Removed deprecated scripts and updated Husky configuration
  • Removed scripts/generateDocs.mjs, scripts/postCss.mjs, and scripts/staticStyles-template.js
  • Updated .husky/_/husky.sh with deprecation notice
scripts/generateDocs.mjs
scripts/postCss.mjs
scripts/staticStyles-template.js
.husky/_/husky.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

This was linked to issues Oct 1, 2024
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @jordanjones243 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The removal of color definitions for labels in .github/settings.yml seems unintentional. Could you clarify if this was meant to be part of this PR?
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 2 issues found
  • 🟡 Complexity: 1 issue found
  • 🟡 Documentation: 3 issues found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -40,15 +40,15 @@ describe('auro-card', () => {
});

it('auro-hyperlink is rendered when `href` attribute is present', async () => {
const el = await fixWebComponent( "/");
const link = el.shadowRoot.querySelectorAll('auro-hyperlink');
Copy link

Choose a reason for hiding this comment

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

question (testing): Update test to use attribute selector instead of tag name

The test has been updated to use an attribute selector '[auro-hyperlink]' instead of the tag name 'auro-hyperlink'. While this change aligns with the implementation, it's important to ensure that this new selector correctly identifies the hyperlink element in all scenarios.

@@ -40,15 +40,15 @@ describe('auro-card', () => {
});

it('auro-hyperlink is rendered when `href` attribute is present', async () => {
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Add test for dynamic tag generation

With the introduction of dynamic tag generation using this.hyperlinkTag, it would be beneficial to add a test that verifies the correct tag is being generated and used based on the version. This ensures that the new versioning logic is working as expected.

it('auro-hyperlink is rendered when `href` attribute is present', async () => {
  const el = await fixWebComponent("/");
  const link = el.shadowRoot.querySelector('auro-hyperlink');
  expect(link).to.exist;
});

it('generates correct hyperlink tag based on version', async () => {
  const el = await fixWebComponent("/");
  el.version = '2.0';
  await el.updateComplete;
  const link = el.shadowRoot.querySelector('auro-hyperlink-v2');
  expect(link).to.exist;
});


### Recommended Use and Version Control

There are two important parts of every Auro component. The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> and the custom clement. The class is exported and then used as part of defining the Web Component. When importing this component as described in the <a href="#install">install</a> section, the class is imported and the `auro-card` custom element is defined automatically.
Copy link

Choose a reason for hiding this comment

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

issue (documentation): Typo: 'custom clement' should be 'custom element'


### Recommended Use and Version Control

There are two important parts of every Auro component. The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> and the custom clement. The class is exported and then used as part of defining the Web Component. When importing this component as described in the <a href="#install">install</a> section, the class is imported and the `auro-card` custom element is defined automatically.
Copy link

Choose a reason for hiding this comment

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

issue (documentation): Typo: 'custom clement' should be 'custom element'

Comment on lines +787 to +789
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-card', AuroCard);
Copy link

Choose a reason for hiding this comment

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

question (documentation): Unusual usage of RuntimeUtils.default.prototype.registerComponent

Is this the correct way to use the registerComponent method? It seems unusual to access it via default.prototype. Could you clarify if this is the intended usage?

import { LitElement, html } from "lit";
/* eslint-disable lit/no-invalid-html, lit/binding-positions */

import { LitElement} from "lit";
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring to use a base component for common functionality.

While the changes introduce important functionality for dependency management and versioning, they significantly increase the complexity of the AuroCard component. We suggest refactoring to reduce complexity while maintaining the desired functionality:

  1. Move versioning and runtime utilities to a higher level:
    Instead of importing and initializing these in each component, consider creating a base component or mixin that handles these concerns:

    import { LitElement } from "lit";
    import AuroLibraryRuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';
    import { AuroDependencyVersioning } from '@aurodesignsystem/auro-library/scripts/runtime/dependencyTagVersioning.mjs';
    
    export class AuroBaseElement extends LitElement {
      constructor() {
        super();
        this.runtimeUtils = new AuroLibraryRuntimeUtils();
        this.versioning = new AuroDependencyVersioning();
      }
    
      firstUpdated() {
        this.runtimeUtils.handleComponentTagRename(this, this.tagName.toLowerCase());
      }
    
      getVersionedTag(tagName, version, component) {
        return this.versioning.generateTag(tagName, version, component);
      }
    }
  2. Simplify the AuroCard component by extending the base element:

    import { html } from 'lit/static-html.js';
    import { AuroBaseElement } from './AuroBaseElement.js';
    import { AuroHyperlink } from '@aurodesignsystem/auro-hyperlink/src/auro-hyperlink.js';
    import hyperlinkVersion from './hyperlinkVersion';
    
    export class AuroCard extends AuroBaseElement {
      constructor() {
        super();
        this.setAttribute('role', 'article');
        this.hyperlinkTag = this.getVersionedTag('auro-hyperlink', hyperlinkVersion, AuroHyperlink);
      }
    
      // ... rest of the component code
    }

This approach maintains the functionality while reducing complexity in individual components. It centralizes the handling of cross-cutting concerns like versioning and runtime utilities, making the code more maintainable and easier to understand.

@jordanjones243 jordanjones243 merged commit 5208525 into beta Oct 1, 2024
4 checks passed
@jordanjones243 jordanjones243 deleted the jjones/betaTechDebt branch October 1, 2024 22:14
@blackfalcon
Copy link
Member

🎉 This PR is included in version 4.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Add custom tag generated version of auro-hyperlink Theme support
2 participants