Socket
Socket
Sign inDemoInstall

@hig/themes

Package Overview
Dependencies
Maintainers
5
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hig/themes - npm Package Compare versions

Comparing version 0.1.0-alpha.2e38833e to 0.1.0-alpha.39d3c760

src/themes/HIGDarkBlueTheme.js

10

build/index.es.js

@@ -9,2 +9,7 @@ import PropTypes from 'prop-types';

var HIGDarkBlueTheme = {
themeId: 'hig-dark-blue',
themeClass: 'hig--dark-blue-theme'
};
var MatrixTheme = {

@@ -87,3 +92,4 @@ themeId: 'matrix',

value: function render() {
return this.props.children(this.context);
var theme = this.context.themeId && this.context.themeClass ? this.context : HIGLightTheme;
return this.props.children(theme);
}

@@ -116,2 +122,2 @@ }]);

export { HIGLightTheme, MatrixTheme, index as ThemeContext };
export { HIGLightTheme, HIGDarkBlueTheme, MatrixTheme, index as ThemeContext };

9

build/index.js

@@ -15,2 +15,7 @@ 'use strict';

var HIGDarkBlueTheme = {
themeId: 'hig-dark-blue',
themeClass: 'hig--dark-blue-theme'
};
var MatrixTheme = {

@@ -93,3 +98,4 @@ themeId: 'matrix',

value: function render() {
return this.props.children(this.context);
var theme = this.context.themeId && this.context.themeClass ? this.context : HIGLightTheme;
return this.props.children(theme);
}

@@ -123,3 +129,4 @@ }]);

exports.HIGLightTheme = HIGLightTheme;
exports.HIGDarkBlueTheme = HIGDarkBlueTheme;
exports.MatrixTheme = MatrixTheme;
exports.ThemeContext = index;
{
"name": "@hig/themes",
"version": "0.1.0-alpha.2e38833e",
"version": "0.1.0-alpha.39d3c760",
"description": "HIG theme definitions and supporting components",

@@ -8,10 +8,10 @@ "author": "Autodesk Inc.",

"homepage": "https://hig.autodesk.com",
"publishConfig": {
"access": "public"
},
"main": "build/index.js",
"module": "build/index.es.js",
"dependencies": {
"@hig/banner": "0.2.0-alpha.2e38833e",
"@hig/styles": "0.1.0-alpha.2e38833e"
},
"devDependencies": {
"@hig/scripts": "0.2.0-alpha.2e38833e"
"@hig/scripts": "0.2.0-alpha.39d3c760",
"@hig/styles": "0.1.0-alpha.39d3c760"
},

@@ -18,0 +18,0 @@ "peerDependencies": {

@@ -5,2 +5,8 @@ # ThemeContext component

## Getting started
```
yarn add @hig/themes
```
## Provide a theme to components

@@ -15,2 +21,2 @@ ```

}
```
```

@@ -9,11 +9,12 @@ import React from "react";

import Banner from "@hig/banner";
import Banner, { AVAILABLE_TYPES as BANNER_TYPES } from "@hig/banner";
import readme from '../../README.md';
import ThemeContext from "../ThemeContext";
import HIGLightTheme from "../themes/HIGLightTheme";
import HIGDarkBlueTheme from "../themes/HIGDarkBlueTheme";
import MatrixTheme from "../themes/MatrixTheme";
const typeOptions = makeSelectOptions(Banner.types);
const themeOptions = {
"hig-light": "HIG Light",
"hig-dark-blue": "HIG Dark Blue",
"matrix": "BIM360 Matrix"

@@ -24,2 +25,3 @@ }

"hig-light": HIGLightTheme,
"hig-dark-blue": HIGDarkBlueTheme,
"matrix": MatrixTheme

@@ -36,8 +38,13 @@ }

const theme = select('Theme', themeOptions, 'hig-light');
const bannerType = select("Banner type", typeOptions, Banner.types[0]);
return (
<ThemeContext.Provider value={themes[theme]}>
<Banner type={bannerType}>{`This message presented in ${themeOptions[theme]} theme`}</Banner>
<div>
{BANNER_TYPES.map((type) => (
<div style={{ marginBottom: "20px" }}>
<Banner type={type}>{`This ${type} message presented in ${themeOptions[theme]} theme`}</Banner>
</div>
))}
</div>
</ThemeContext.Provider>
);
}));
export { default as HIGLightTheme } from './themes/HIGLightTheme';
export { default as HIGDarkBlueTheme } from './themes/HIGDarkBlueTheme';
export { default as MatrixTheme } from './themes/MatrixTheme';
export { default as ThemeContext } from './ThemeContext';

@@ -17,2 +17,6 @@ import * as index from "./index";

{
name: "HIGDarkBlueTheme",
value: expect.any(Object)
},
{
name: "MatrixTheme",

@@ -19,0 +23,0 @@ value: expect.any(Object)

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import themeContextShape from './shape';
import HIGLightTheme from "../themes/HIGLightTheme";

@@ -14,4 +15,5 @@ export default class Consumer extends Component {

render() {
return this.props.children(this.context);
const theme = (this.context.themeId && this.context.themeClass) ? this.context : HIGLightTheme;
return this.props.children(theme);
}
}
import { mount } from "enzyme";
import React from "react";
import HIGLightTheme from "../themes/HIGLightTheme";
import ThemeContext from "./index";
const TestTheme = {
themeId: 'test-theme',
themeClass: 'hig--test-theme'
}
themeId: "test-theme",
themeClass: "hig--test-theme"
};
describe("ThemeContext", () => {
describe("with a provided theme", () => {
let renderFunction = jest.fn();
renderFunction.mockReturnValue(null);
const renderFunction = jest.fn();
let wrapper;
beforeEach(() => {
renderFunction.mockReset();
renderFunction.mockReturnValue(null);
});
beforeEach(() => {
wrapper = mount(
it("provides the theme to the consumer", () => {
mount(
<ThemeContext.Provider value={TestTheme}>

@@ -24,8 +28,12 @@ <ThemeContext.Consumer>{renderFunction}</ThemeContext.Consumer>

);
});
it(`provides the theme to the consumer`, () => {
expect(renderFunction).toHaveBeenCalledWith(TestTheme);
});
it("provides the default theme without a provider", () => {
mount(<ThemeContext.Consumer>{renderFunction}</ThemeContext.Consumer>);
expect(renderFunction).toHaveBeenCalledWith(HIGLightTheme);
});
});
});
export { default as HIGLightTheme } from "./HIGLightTheme";
export { default as HIGDarkBlueTheme } from "./HIGDarkBlueTheme";
export { default as MatrixTheme } from "./MatrixTheme";

@@ -10,2 +10,6 @@ import * as index from "./index";

{
name: "HIGDarkBlueTheme",
value: expect.any(Object)
},
{
name: "MatrixTheme",

@@ -12,0 +16,0 @@ value: expect.any(Object)

@@ -1,4 +0,4 @@

import { HIGLightTheme, MatrixTheme } from "./index";
import { HIGLightTheme, HIGDarkBlueTheme, MatrixTheme } from "./index";
[HIGLightTheme, MatrixTheme].forEach(theme => {
[HIGLightTheme, HIGDarkBlueTheme, MatrixTheme].forEach(theme => {
describe(`${theme}`, () => {

@@ -5,0 +5,0 @@ it("has a themeId", () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc