
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
boundless-segmented-control
Advanced tools
A control containing multiple buttons, only one of which can be active at a time.
SegmentedControl has many potential uses, the most common being:
Essentially, it behaves like a radio group without actually using input controls. Only one option can be selected at a time.
getSelectedOption()
retrieves the option that is selectedgetSelectedOptionIndex()
retrieves the index of the option that is selectedselectOption(option)
allows for programmatic switching of the active SegmentedControl optionselectOptionByKey(key, value)
allows for programmatic switching of the active SegmentedControl option using a unique keyselectOptionIndex(index)
allows for programmatic switching of the active SegmentedControl option by indexnpm i boundless-segmented-control --save
Then use it like:
/** @jsx createElement */
import { capitalize, map } from 'lodash';
import { createElement, PureComponent } from 'react';
import SegmentedControl from 'boundless-segmented-control';
import Image from 'boundless-image';
export default class SegmentedControlDemo extends PureComponent {
state = {
selectedGroupIndex: 0,
groups: [ {
key: 'galaxies',
images: [
{ alt: 'Triangulum (M33)', src: 'https://c1.staticflickr.com/5/4128/5043159769_f382995a9b_b.jpg' },
{ alt: 'Andromeda (M31)', src: 'https://c1.staticflickr.com/7/6215/6242076308_d01dccd1b4_b.jpg' },
{ alt: 'Milky Way Galactic Core', src: 'https://c2.staticflickr.com/6/5236/5896162967_a656cf460a_b.jpg' },
{ alt: 'M77', src: 'http://farm9.static.flickr.com/8668/15864469305_b3db67dd1d_m.jpg' },
{ alt: 'Whirlpool (M51)', src: 'https://apod.nasa.gov/apod/image/0602/m51center_hst.jpg' },
],
}, {
key: 'nebulae',
images: [
{ alt: 'Horsehead', src: 'https://c1.staticflickr.com/9/8244/8663227196_1e3719be69_b.jpg' },
{ alt: 'Dust of Orion', src: 'https://c1.staticflickr.com/5/4113/5216868239_b53b8d5e80_b.jpg' },
{ alt: 'Carina', src: 'https://c1.staticflickr.com/3/2796/4398656115_ceb9a987ce_b.jpg' },
{ alt: 'Trifid', src: 'https://c1.staticflickr.com/1/468/19550653503_e4e0017579_b.jpg' },
{ alt: 'Medusa', src: 'https://s-media-cache-ak0.pinimg.com/736x/df/5f/71/df5f7105d0de64246395fdda57f51ddf.jpg' },
],
}, {
key: 'planets',
images: [
{ alt: 'Mercury', src: 'https://c1.staticflickr.com/9/8228/8497927563_00dcb3fe09_b.jpg' },
{ alt: 'Venus', src: 'http://vedichealing.com/wp-content/uploads/2013/03/Venusflickr-300x300.jpg' },
{ alt: 'Earth', src: 'https://c1.staticflickr.com/3/2084/2222523486_5e1894e314_b.jpg' },
{ alt: 'Mars', src: 'https://c2.staticflickr.com/4/3079/3191775310_bc6a8234d3.jpg' },
{ alt: 'Jupiter', src: 'https://c2.staticflickr.com/4/3935/15652333232_6b44ff9cbf_b.jpg' },
],
} ],
}
handleOptionSelected = (_, index) => this.setState({ selectedGroupIndex: index })
render() {
return (
<div className='demo-segmented-control'>
<p>Which astronomical features would you like to view?</p>
<SegmentedControl
options={map(this.state.groups, (group) => ({ children: capitalize(group.key) }))}
onOptionSelected={this.handleOptionSelected} />
<br />
<div className='spread'>
{this.state.groups[this.state.selectedGroupIndex].images.map((props) => (
<Image key={props.alt} {...props} />
))}
</div>
</div>
);
}
}
SegmentedControl can also just be directly used from the main Boundless library. This is recommended when you're getting started to avoid maintaining the package versions of several components:
npm i boundless --save
the ES6 import
statement then becomes like:
import { SegmentedControl } from 'boundless';
Note: only top-level props are in the README, for the full list check out the website.
options
· prop objects to be applied against the SegmentedControl buttons, accepts any valid React props
options={[{
children: 'Foo',
className: 'foo',
}, {
children: <span>Bar</span>,
'data-id': 'bar',
}]}
Expects | Default Value |
---|---|
arrayOf(object) | [] |
*
· any React-supported attribute
Expects | Default Value |
---|---|
any | n/a |
defaultOptionSelectedIndex
· sets the initial selected option on first mount
Expects | Default Value |
---|---|
number | 0 |
onOptionSelected
· called when a child element becomes selected with the option and option index
Expects | Default Value |
---|---|
function | () => {} |
optionComponent
· provide a customized component type if desired, either a HTML element name or ReactComponent
Expects | Default Value |
---|---|
string or function | 'button' |
You can see what variables are available to override in variables.styl.
// Redefine any variables as desired, e.g:
color-accent = royalblue
// Bring in the component styles; they will be autoconfigured based on the above
@require "node_modules/boundless-segmented-control/style"
If desired, a precompiled plain CSS stylesheet is available for customization at /build/style.css
, based on Boundless's default variables.
FAQs
A control containing multiple buttons, only one of which can be active at a time.
We found that boundless-segmented-control demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.