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

Add Typescript support #90

Merged
merged 2 commits into from
Aug 18, 2020
Merged

Conversation

fedeci
Copy link
Contributor

@fedeci fedeci commented Aug 16, 2020

Description

This pull request adds index.d.ts file to provide typescript type information about contrast-colors module.
This closes #74

Motivation

This simplify the use of the module in typescript projects.

Screenshots

To-do list

  • This pull request is ready to merge.

@fedeci fedeci closed this Aug 18, 2020
@fedeci fedeci reopened this Aug 18, 2020
@NateBaldwinDesign
Copy link
Collaborator

Thank you for this contribution @fedeci !

@NateBaldwinDesign NateBaldwinDesign merged commit 15de9ae into adobe:main Aug 18, 2020
@fedeci
Copy link
Contributor Author

fedeci commented Aug 18, 2020

You're welcome!

@fedeci fedeci deleted the typescript-support branch August 18, 2020 13:53
@NateBaldwinDesign
Copy link
Collaborator

FYI this feature added to release 1.0.0-alpha.7

@KirdesMF
Copy link

KirdesMF commented Sep 5, 2020

is it possible to create an interface for the colorScales parameter in the generateAdaptiveTheme function ?
for example :

const uiRatios = [1, 1.5, 2, 2.5, 3, 4.5, 7, 11, 16];

const redScale: ColorScales = {
   name: 'red',
   ratios: uiRatios,
   colorKeys:  [],
   colorspace: 'HEX'

}

const blueScale: ColorScales = {
   name: 'blue',
   ratios: uiRatios,
   colorKeys:  [],
   colorspace: 'HEX'
}

generateAdaptiveTheme({
   colorScales: [redScale, blueScale],
   baseScale: "red"
})

for now I'm just extending the ContrastColors module

import '@adobe/leonardo-contrast-colors';
declare module '@adobe/leonardo-contrast-colors' {
   export interface ColorScales {
      name: string;
      colorKeys: string[];
      colorspace: Colorspace;
      ratios: number[] | { [key: string]: number };
   }
}

btw really great work, impressive !!

@KirdesMF
Copy link

KirdesMF commented Sep 6, 2020

and there is an issue with the Colorspace union type:

  type Colorspace = 'CAM02' | 'CAM02p' | 'LCH' | 'LAB' | 'HSL' | 'HSLuv' | 'RGB' | 'HSV' | 'HEX';

image

HEX provides an issue.

then rn I'm good with :

import '@adobe/leonardo-contrast-colors';
declare module '@adobe/leonardo-contrast-colors' {
   export type ColorScales = {
      name: string;
      colorKeys: string[];
      colorspace: Exclude<Colorspace, 'HEX'>;
      ratios: number[] | { [key: string]: number };
   };
}

@KirdesMF
Copy link

KirdesMF commented Sep 6, 2020

Thx ! Next time time should I create an issue ?

@fedeci
Copy link
Contributor Author

fedeci commented Sep 6, 2020

If the PR has already been merged it is better to create an issue. 👍

@GarthDB GarthDB mentioned this pull request Mar 14, 2024
thierryc pushed a commit to thierryc/leonardo that referenced this pull request Mar 29, 2024
* feat: add Typescript support

* feat: update index.d.ts
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.

Typescript support
3 participants