Convert an Angular Material M2 theme to M3

The documentation from the Angular Material team is rather scarce and missing crucial information on how to transition from M2 to M3 for an existing theme. In our situation we have the following code:

$green-palette: (
  50: #e7f7eb,
  100: #c5eace,
  200: #a0dcb0,
  300: #77d090,
  400: #57c578,
  // Main color:
  500: #33ba60,
  600: #2aaa56,
  700: #1f984a,
  800: #13873f,
  900: #00672b,
  contrast: (
    50: vars.$dark-primary-text,
    100: vars.$dark-primary-text,
    200: vars.$dark-primary-text,
    300: vars.$dark-primary-text,
    400: vars.$dark-primary-text,
    500: vars.$light-primary-text,
    600: vars.$light-primary-text,
    700: vars.$light-primary-text,
    800: vars.$light-primary-text,
    900: vars.$light-primary-text,
  ),
);

// And other palettes

We use these palettes in the theme configuration:

$primary-palette: mat.m2-define-palette(p.$green-palette, 500);
$accent-palette: mat.m2-define-palette(p.$orange-palette, 300, 200, 500);
$warn-palette: mat.m2-define-palette(p.$red-palette, 400, 300, 600);
$link-palette: mat.m2-define-palette(p.$blue-palette, 700, 400, 800);

$theme: mat.m2-define-light-theme(
  (
    color: (
      primary: $primary-palette,
      accent: $accent-palette,
      warn: $warn-palette,
    ),
    typography: t.$typography,
    density: 0,
  )
);

// Adjust background palette
$theme: f.theme-background-change($theme, "status-bar", #e0e0e0);
$theme: f.theme-background-change($theme, "app-bar", #f5f5f5);
$theme: f.theme-background-change($theme, "background", #f6f6f6);
$theme: f.theme-background-change($theme, "hover", rgba(black, 0.04));
$theme: f.theme-background-change($theme, "card", white);
$theme: f.theme-background-change($theme, "dialog", white);
$theme: f.theme-background-change($theme, "disabled-button", rgba(black, 0.12));
$theme: f.theme-background-change($theme, "raised-button", white);
$theme: f.theme-background-change($theme, "focused-button", rgba(black, 0.12));
$theme: f.theme-background-change($theme, "selected-button", #e0e0e0);
$theme: f.theme-background-change($theme, "selected-disabled-button", #bdbdbd);
$theme: f.theme-background-change($theme, "disabled-button-toggle", #eeeeee);
$theme: f.theme-background-change($theme, "unselected-chip", #e0e0e0);
$theme: f.theme-background-change($theme, "disabled-list-option", #eeeeee);
$theme: f.theme-background-change($theme, "tooltip", black);

// Adjust foreground palette
$theme: f.theme-foreground-change($theme, "base", black);
$theme: f.theme-foreground-change($theme, "divider", rgba(black, 0.12));
$theme: f.theme-foreground-change($theme, "dividers", rgba(black, 0.12));
$theme: f.theme-foreground-change($theme, "disabled", rgba(black, 0.38));
$theme: f.theme-foreground-change($theme, "disabled-button", rgba(black, 0.26));
$theme: f.theme-foreground-change($theme, "disabled-text", v.$dark-disabled-text);
$theme: f.theme-foreground-change($theme, "elevation", black);
$theme: f.theme-foreground-change($theme, "hint-text", rgba(black, 0.38));
$theme: f.theme-foreground-change($theme, "secondary-text", v.$dark-secondary-text);
$theme: f.theme-foreground-change($theme, "icon", v.$dark-secondary-text);
$theme: f.theme-foreground-change($theme, "icons", v.$dark-secondary-text);
$theme: f.theme-foreground-change($theme, "text", v.$dark-primary-text);
$theme: f.theme-foreground-change($theme, "slider-min", v.$dark-primary-text);
$theme: f.theme-foreground-change($theme, "slider-off", rgba(black, 0.26));
$theme: f.theme-foreground-change($theme, "slider-off-active", rgba(black, 0.38));

See How to set background palette in custom theme of Angular Material? for more information on the theme-background-change and theme-foreground-change functions.

Also, the typography configuration is a whole other matter and I will not go into this.

The question is how can I convert this into a M3 theme? I can generate a theme configuration file using ng generate @angular/material:m3-theme but this will not match the current palettes at all as it will not use the current primary and secondary colors as-is but as some starting point.

Also, where should I define my changed foreground and background colors in the new M3 theme?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật