Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hig/theme-context

Package Overview
Dependencies
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hig/theme-context - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

48

build/index.es.js

@@ -12,17 +12,47 @@ import createReactContext from 'create-react-context';

function isPresent(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
function resolvedRolesProxy(roles, theme) {
if ((typeof roles === "undefined" ? "undefined" : _typeof(roles)) !== "object") return roles;
return new Proxy(roles, {
get: function get(obj, prop) {
if (!isPresent(obj, prop)) {
/* eslint-disable-next-line no-console */
console.error("Role " + prop.toString() + " does not exist");
return obj[prop];
}
var hasRoleDeprecationInfo = isPresent(theme, "metadata") && isPresent(theme.metadata, "__deprecated__") && isPresent(theme.metadata.__deprecated__, prop);
if (hasRoleDeprecationInfo) {
var roleDeprecationInfo = theme.metadata.__deprecated__[prop];
var equivalencyInfo = roleDeprecationInfo.equivalent ? " and has been renamed to " + roleDeprecationInfo.equivalent.toString() + "." : ".";
/* eslint-disable-next-line no-console */
console.warn("Role " + prop.toString() + " is deprecated" + equivalencyInfo);
}
return obj[prop];
}
});
}
function createThemeProxy(theme) {
return new Proxy(theme, {
get: function get(obj, propertyName) {
var value = obj[propertyName];
var isValidProperty = Object.prototype.hasOwnProperty.call(obj, propertyName);
get: function get(obj, prop) {
var value = obj[prop];
if (!isValidProperty) {
if (prop.toString() === "resolvedRoles") return resolvedRolesProxy(value, theme);
if (!isPresent(obj, prop)) {
/* eslint-disable-next-line no-console */
console.error("Role " + propertyName.toString() + " does not exist");
return null;
console.error("Property " + prop.toString() + " does not exist.");
return value;
}
if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value !== null) {
return createThemeProxy(value);
}
if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value !== null) return createThemeProxy(value);

@@ -29,0 +59,0 @@ return value;

@@ -19,17 +19,47 @@ 'use strict';

function isPresent(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
function resolvedRolesProxy(roles, theme) {
if ((typeof roles === "undefined" ? "undefined" : _typeof(roles)) !== "object") return roles;
return new Proxy(roles, {
get: function get(obj, prop) {
if (!isPresent(obj, prop)) {
/* eslint-disable-next-line no-console */
console.error("Role " + prop.toString() + " does not exist");
return obj[prop];
}
var hasRoleDeprecationInfo = isPresent(theme, "metadata") && isPresent(theme.metadata, "__deprecated__") && isPresent(theme.metadata.__deprecated__, prop);
if (hasRoleDeprecationInfo) {
var roleDeprecationInfo = theme.metadata.__deprecated__[prop];
var equivalencyInfo = roleDeprecationInfo.equivalent ? " and has been renamed to " + roleDeprecationInfo.equivalent.toString() + "." : ".";
/* eslint-disable-next-line no-console */
console.warn("Role " + prop.toString() + " is deprecated" + equivalencyInfo);
}
return obj[prop];
}
});
}
function createThemeProxy(theme) {
return new Proxy(theme, {
get: function get(obj, propertyName) {
var value = obj[propertyName];
var isValidProperty = Object.prototype.hasOwnProperty.call(obj, propertyName);
get: function get(obj, prop) {
var value = obj[prop];
if (!isValidProperty) {
if (prop.toString() === "resolvedRoles") return resolvedRolesProxy(value, theme);
if (!isPresent(obj, prop)) {
/* eslint-disable-next-line no-console */
console.error("Role " + propertyName.toString() + " does not exist");
return null;
console.error("Property " + prop.toString() + " does not exist.");
return value;
}
if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value !== null) {
return createThemeProxy(value);
}
if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value !== null) return createThemeProxy(value);

@@ -36,0 +66,0 @@ return value;

@@ -0,1 +1,8 @@

# [@hig/theme-context-v2.1.0](https://github.com/Autodesk/hig/compare/@hig/theme-context@2.0.0...@hig/theme-context@2.1.0) (2019-02-05)
### Features
* console warn about use of deprecated roles ([5b85653](https://github.com/Autodesk/hig/commit/5b85653))
# [@hig/theme-context-v2.0.0](https://github.com/Autodesk/hig/compare/@hig/theme-context@1.0.1...@hig/theme-context@2.0.0) (2019-01-17)

@@ -2,0 +9,0 @@

4

package.json
{
"name": "@hig/theme-context",
"version": "2.0.0",
"version": "2.1.0",
"description": "ThemeContext components to ease adoption of theme data from React components",

@@ -21,3 +21,3 @@ "author": "Autodesk Inc.",

"dependencies": {
"@hig/theme-data": "^1.5.0",
"@hig/theme-data": "^2.1.0",
"create-react-context": "^0.2.3",

@@ -24,0 +24,0 @@ "prop-types": "^15.6.1"

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

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [Getting started](#getting-started)
- [Provide a theme to components](#provide-a-theme-to-components)
- [Consume theme values in a component](#consume-theme-values-in-a-component)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Getting started

@@ -13,4 +23,5 @@

## Provide a theme to components
```jsx
import HIGDarkBlueTheme from '@hig/theme-data/build/json/darkBlueMediumDensityTheme/theme.json';
import HIGDarkBlueTheme from '@hig/theme-data/build/esm/darkBlueMediumDensityTheme';
import ThemeContext from '@hig/theme-context';

@@ -25,2 +36,4 @@

For information on customizing a theme or importing theme data in different formats, see the [theme-data README](../packages/theme-data/README.md).
## Consume theme values in a component

@@ -27,0 +40,0 @@ ```jsx

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