Guide on transpiling web components created with TypeScript and SCSS to JavaScript and CSS within the Material You design system, based on Material Design 3

Material Web featuring Material Design 2 enables the use of web components such as mwc-button. This can be done by importing a module from unpkg or transpiling (or bundling) it to a JavaScript file (e.g. mwc-bundle-button.js) from the NPM package.

<script defer
        type="module"
        src='https://unpkg.com/@@material/mwc-button?module'>
</script>
or
<script defer
        type="module"
        src='../(path)/web-components/mwc-bundle-button.js'>
</script>

<mwc-button label="button label"></mwc-button>

When it comes to Material Web with Material You (Material Design 3), as of June 29, 2022, there is still no NPM package (@material/web) available.

I am eager to experiment with some web components using Material You, but I am unsure about how to transpile the repository into JavaScript files.

My approach so far has been:

  1. Cloning the Lit starter kit (potentially incorporating Lit into material-web)
  2. Downloading the material-web repository within the [Lit starter kit]
  3. build (possibly using tsc) for transpiling icon.ts into JavaScript files
  4. rollup -c to bundle everything into one JavaScript file

However, I encountered the error

TS2307: Cannot find module './lib/icon-styles.css' or its corresponding type declarations.
.

Am I on the right track? (Can I achieve my goal by resolving these errors?)

Or, could there be a misunderstanding in my approach?

Answer №1

on the date 8/31/2022, there will be an exciting NPM package known as @material/web.

After that, I will have access to web components such as <md-outlined-button>, by utilizing rollup.js for bundling purposes (more information can be found at here). This will allow me to compile all necessary resources into a handy JavaScript file named bundle-md-outlined-button.js.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A step-by-step guide for setting up MongoDB on a "Blank Node.js Console Application" project in VS2015 with TypeScript

Here is my process: First, I installed MongoDB Next, I opened Visual Studio 2015 Then, I created a new project by going to "File" -> "New" -> "Project" -> "TypeScript" -> "Blank Node.js Console Application" After that, I opened the project fo ...

The JavaScript functions are not loading within the onload event handler

I've got an HTML document that contains some Script sections. I've consolidated all the functions within a single Script Tag. Now, I want to be able to utilize these methods in both the onload and onclick events. Below is the HTML file with all t ...

Creating a Thrilling Triple Image Transformation on Hover using Material-UI

Here is a Codepen showcasing a triple hover effect on an image: Codepen I attempted to recreate this effect as a styled component in React Typescript using MUI and MUI Image, but encountered an error with my styling that is preventing it from working in m ...

Angular 8 delivers an observable as a result following a series of asynchronous requests

I am working on a simple function that executes 3 asynchronous functions in sequence: fetchData() { this.fetchUsers('2') .pipe( flatMap((data: any) => { return this.fetchPosts(data.id); }), fl ...

I'm facing issues with Angular commands not functioning properly even after installing the Angular CLI and configuring the

Every time I attempt to create a new project using Angular CLI by typing: ng n app I encounter the following error message: C:\Users\Venkateshwarn M\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng: ...

Retrieving the value from a concealed checkbox

I have been searching everywhere, but I can't seem to find a solution to this particular issue. There is a hidden checkbox in my field that serves as an identifier for the type of item added dynamically. Here's how I've set it up: <inpu ...

Scrolling seamlessly on websites with a single page

I am developing a single-page website that uses different section IDs instead of multiple pages. It's functioning properly, but I want to implement smooth scrolling to the sections rather than just statically jumping to them on the page. Jsfiddle: ht ...

What is preventing me from retrieving WP custom fields value or post ID using Ajax?

After successfully generating a link based on the visitor's location, I encountered an issue with caching when using full-page caching. To address this problem, I decided to implement AJAX to dynamically load the link. While my code worked well in ret ...

creating a distinct angular service for every controller

Lately, I've been utilizing Angular services to store my commonly used codes that are required across different parts of my project. However, I have encountered an issue where variables in the service are shared between controllers. This means that if ...

Tips for determining the zoom factor through mouse scrolling using jQuery

Is there a way to zoom in on a page when the user scrolls using ctrl + ,? If I determine the Zoom factor, can I then zoom in on the current page based on that factor? For example, if the zoom factor is 1.44, can I convert this to 144% and carry out the ...

Utilizing NextJS Image Component in Conjunction with Auth0

I have been working on integrating auth0 with nextJS and encountered an issue with the next.js Image component. Let's review the code snippet: import Image from "next/image" import { useUser } from "@auth0/nextjs-auth0" export def ...

Simplify TypeScript code by converting null or undefined values to numbers

When working with a product, it's important to keep in mind that it can be undefined or null; furthermore, the price within the product can also be undefined or null. For example: getClasses(key: number): string { let product = this.mo ...

Tips for looping through the new element that has been added to an array from the database query result

I am faced with a challenge involving querying a mysql database using each element of an array in Node.js. If a specific condition is met, I need to append additional elements to the same array and iterate through them as well. As I am new to Node.js, I a ...

What is the best way to pass a form result from a parent component to a child component

In the setup, there is a child component containing a form with various options for selection. The goal is to capture the user's selection and process it within this child component. Despite attempting to utilize an event in the parent component, the ...

Issue with disabling input field when selecting an option from a drop down menu

<div class="form-group form-animate-text col-lg-6 col-xs-12 col-md-6" > <select class="form-text" id="val_equipfc" name="val_equipfc" onChange="checkOption(this)" required> <option value = "A">Yes</option> < ...

Enhance fullness to facial features

Creating walls by forming faces using specific points is a successful process for me. However, I am now looking to add thickness to these walls, and I am unsure of the best approach. Below is the code I currently use to create the walls: makeWall(start, ...

Preventing driver closure during test suites in Appium/Webdriverio: a step-by-step guide

Currently, I am in the process of testing a react native application with a specific test suite and test cases. The test case files I am working with are: login.ts doActionAfterLogin_A.ts Test Suite: [login.ts, doActionAfterLogin_A.ts] Issue at Hand: W ...

What is the best way to automatically log out a user once their session cookie has expired during an online exam?

While developing an MVC ExpressJS Test app, I encountered an issue with auto-logout functionality for users who stop answering test questions. The error message "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client" keeps app ...

Unable to save the outcome in the session while using async waterfall

I have run a series of methods using async.waterfall which returns a result. I save this result in a request.session variable for later use with Ajax. However, I am facing an issue where I can set the value of the session variable initially but am unable t ...

Display an array comprising of other arrays

function PersonXYZ(fName, lName) { this.lastName = lName; this.firstName = fName; this.grades = []; this.grades.push([4, 67, 5]); this.grades.push([41, 63, 5]); this.grades.push([4, 67, 55]); } var person = new PersonXYZ('John', 'Doe&apos ...