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

@code.gov/code-gov-style

Package Overview
Dependencies
Maintainers
2
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@code.gov/code-gov-style - npm Package Compare versions

Comparing version 1.7.2 to 1.7.3

38

assets/js/web_components.js

@@ -69,2 +69,24 @@ 'use strict';

parseOptions() {
const rawOptions = this.getAttribute('options');
let parsedOptions = null;
try {
parsedOptions = JSON.parse(rawOptions);
} catch (error) {
console.error("[filter-box] failed to parse rawOptions:", rawOptions);
throw error;
}
if (parsedOptions) {
this.options = parsedOptions.map(option => {
if (typeof option === "object" && option.name && option.value) {
return { name: option.name, value: option.value, selected: false };
} else {
return { name: option, value: option, selected: false };
}
});
} else {
this.options = [];
}
}
update() {

@@ -80,17 +102,3 @@

this.title = this.getAttribute('title');
const rawOptions = this.getAttribute('options');
let parsedOptions = null;
try {
parsedOptions = JSON.parse(rawOptions);
} catch (error) {
console.error("[filter-box] failed to parse rawOptions:", rawOptions);
throw error;
}
if (parsedOptions) {
this.options = parsedOptions.map(option => {
return { name: option, value: option, selected: false };
});
} else {
this.options = [];
}
this.parseOptions();

@@ -97,0 +105,0 @@ container.className = "filter-box";

@@ -69,2 +69,24 @@ 'use strict';

parseOptions() {
const rawOptions = this.getAttribute('options');
let parsedOptions = null;
try {
parsedOptions = JSON.parse(rawOptions);
} catch (error) {
console.error("[filter-box] failed to parse rawOptions:", rawOptions);
throw error;
}
if (parsedOptions) {
this.options = parsedOptions.map(option => {
if (typeof option === "object" && option.name && option.value) {
return { name: option.name, value: option.value, selected: false };
} else {
return { name: option, value: option, selected: false };
}
});
} else {
this.options = [];
}
}
update() {

@@ -80,17 +102,3 @@

this.title = this.getAttribute('title');
const rawOptions = this.getAttribute('options');
let parsedOptions = null;
try {
parsedOptions = JSON.parse(rawOptions);
} catch (error) {
console.error("[filter-box] failed to parse rawOptions:", rawOptions);
throw error;
}
if (parsedOptions) {
this.options = parsedOptions.map(option => {
return { name: option, value: option, selected: false };
});
} else {
this.options = [];
}
this.parseOptions();

@@ -97,0 +105,0 @@ container.className = "filter-box";

@@ -9,5 +9,5 @@ ---

<p>Below you will find the buttons used by code.gov</p>
<p>Below you will find the filter boxes used by code.gov</p>
# Normal Button
# Simple Filter Box
<filter-box

@@ -23,1 +23,14 @@ title="Computer Language"

```
# Advanced Filter Box
You can also pass in a JSON that specifies the display name and value for each option in the selection.
<filter-box
title="Organization Type"
options='[{"name":"Federal Government","value":"federal"},{"name":"State Government","value":"state"},{"name":"Local Government","value":"local"}]'
></filter-box>
```
<filter-box
title="Organization Type"
options='[{"name":"Federal Government","value":"federal"},{"name":"State Government","value":"state"},{"name":"Local Government","value":"local"}]'
></filter-box>
```
{
"name": "@code.gov/code-gov-style",
"version": "1.7.2",
"version": "1.7.3",
"description": "Style for code.gov including buttons, banners, and cards. Inspired by and somewhat based on USWDS.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

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