Normalizes vscode themes and colors
Перейти к файлу
Connor Peet 8fcffda262
update readme
2021-05-28 14:20:19 -07:00
.vscode init 2021-05-28 14:11:06 -07:00
src init 2021-05-28 14:11:06 -07:00
.gitignore init 2021-05-28 14:11:06 -07:00
.npmignore init 2021-05-28 14:11:06 -07:00
CODE_OF_CONDUCT.md CODE_OF_CONDUCT.md committed 2021-05-27 15:45:41 -07:00
LICENSE LICENSE committed 2021-05-27 15:45:42 -07:00
README.md update readme 2021-05-28 14:20:19 -07:00
SECURITY.md SECURITY.md committed 2021-05-27 15:45:43 -07:00
SUPPORT.md SUPPORT.md committed 2021-05-27 15:45:44 -07:00
package.json init 2021-05-28 14:11:06 -07:00
tsconfig.json init 2021-05-28 14:11:06 -07:00
yarn.lock init 2021-05-28 14:11:06 -07:00

README.md

@vscode/theme-color-consumer

This module can consume a VS Code color theme JSON file and output a complete list off all VS Code colors, with defaults and overrides filled in.

Usage

Here's how you might load a VS Code theme in order to make the current document fully capable of styling code made to run in a VS Code webview:

import { ColorTheme, getWebviewProperties } from '@vscode/theme-color-consumer';

const myThemeJson = 'https://raw.githubusercontent.com/connor4312/codesong/master/package.json';

// Use .load() to load the json, passing in a fetcher function. Returns all
// themes defined in the package.json.
const themes = ColorTheme.load(myThemeJson, async url => {
  const res = fetch(url);
  return res.text();
});

// Get the webview colors. Information about the font to use is not included
// in themes and should be passed here as well:
const webviewProps = getWebviewProperties(themes[0], myFontData);

// This returns the 'style' property, as well as a class and data which should
// be applied to the body:
document.body.style = webviewProps.style;
document.body.classList.add(webviewProps.style);
Object.assign(document.body.dataset, webviewProps.dataset);

You can also get individual colors from themes in a strongly-typed wau, for example:

element.style.color = themes[0].getColor('editor.foreground').toString();

Contributing

Setup

  1. Clone VS Code somewhere (by default, in a vscode folder beside this repo)
  2. Set up VS Code, see its contributing guide
  3. Clone this repo, and run yarn to install dependencies.
  4. Run yarn extract [../path/to/vscode] to create a mapping.js file

Process

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.