
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
carbon-menus
Advanced tools
Carbon-Menus is a simple fixed location animation wrapper.
A set of menus for React.
Features include:
npm install carbon-menus
or
yarn add carbon-menus
import { BottomPopup } from 'carbon-menus';
...
render() {
return <BottomPopup open={this.state.open} gutter={40} items={this.items} />;
}
Then use it in your app:
Create a CSS file to define your base elements or use something from Material-UI or something else all together.
index.css
.circle {
height: 50px;
width: 50px;
border-radius: 50%;
border: solid 2px #aaaaaa;
}
.icon {
position: absolute;
margin: auto;
left: 50%;
top: 50%;
font-size: 2em;
transform: translate(-50%, -50%);
}
Create a file in your project to define your JSX.Elements. The only relevant part here is the BottomPopup component which takes the JSX.Element array.
App.tsx
import './index.css';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
IconDefinition,
faAddressBook,
faAddressCard,
faArrowAltCircleLeft,
faBirthdayCake,
faGlassCheers,
} from '@fortawesome/free-solid-svg-icons';
import { BottomPopup } from 'carbon-menus';
interface DemoProps {
nada?: boolean;
}
interface DemoState {
open: boolean;
}
interface Definitions {
color: string;
icon: IconDefinition;
}
const transparency = 0.7;
const colors = [
`rgba(72, 175, 240, ${transparency})`,
`rgba(61, 204, 145, ${transparency})`,
`rgba(255, 179, 102, ${transparency})`,
`rgba(255, 115, 115, ${transparency})`,
`rgba(255, 110, 74, ${transparency})`,
`rgba(255, 102, 161, ${transparency})`,
`rgba(194, 116, 194, ${transparency})`,
`rgba(173, 153, 255, ${transparency})`,
];
const definitons = new Array<Definitions>();
definitons.push({ color: colors[0], icon: faAddressBook });
definitons.push({ color: colors[1], icon: faAddressCard });
definitons.push({ color: colors[2], icon: faArrowAltCircleLeft });
definitons.push({ color: colors[3], icon: faBirthdayCake });
definitons.push({ color: colors[4], icon: faGlassCheers });
class Demo extends Component<DemoProps, DemoState> {
private items: Array<JSX.Element> = new Array<JSX.Element>();
constructor(props: DemoProps) {
super(props);
this.state = {
open: false,
};
for (var item of definitons) {
this.items.push(
<div className="circle" style={{ backgroundColor: item.color }} onClick={() => this.toggleOpen()}>
<FontAwesomeIcon className="icon" icon={item.icon} />
</div>,
);
}
document.body.style.backgroundColor = 'black';
}
private toggleOpen() {
this.setState({ open: !this.state.open });
}
public render(): JSX.Element {
console.log('STATE', this.state);
return (
<div>
<h1>Bottom Popup</h1>
<button onClick={() => this.toggleOpen()}>Toggle</button>
<BottomPopup open={this.state.open} gutter={40} items={this.items} />
</div>
);
}
}
Common props you may want to specify include:
open
- opens the controlgutter
- spacing between the elementsitems
- list of JSX.ElementsanimationDuration
- (optional) duration of the ease animationopen
- opens the controlradius
- radius the elements will be placed around the left sideitems
- list of JSX.ElementsanimationDuration
- (optional) duration of the ease animationFAQs
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 Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.