react-icons/fi#FiCodepen JavaScript Examples
The following examples show how to use
react-icons/fi#FiCodepen.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelectionBar.js From winstall with GNU General Public License v3.0 | 5 votes |
function SelectionBar({ router }) {
const { selectedApps, setSelectedApps } = useContext(SelectedContext);
const [ hideCreatePack, setHideCreatePack ] = useState(false);
useEffect(() => {
if(router.pathname === "/packs/create"){
setHideCreatePack(true);
} else{
setHideCreatePack(false);
};
}, [ router ])
if(selectedApps.length === 0) return <></>;
let handleClear = () => {
// check if confirm exists
// support for iOS safari
if ('confirm' in window && typeof window.confirm === 'function'){
if(window.confirm("Are you sure you want to unselect all the apps?")){
setSelectedApps([]);
}
} else{
setSelectedApps([]);
}
}
return (
<div className="bottomBar">
<div className="container inner">
<div className="appPreview">
<p>Selected {selectedApps.length} apps so far</p>
</div>
<div className="controls">
<button className="clear small" onClick={() => handleClear()} title="Clear selections">
<FiTrash />
</button>
{ !hideCreatePack && (
<Link href="/packs/create">
<button disabled={selectedApps.length >= 5 ? false : true}>
<FiShare />
<em>{selectedApps.length >= 5 ? "Create Pack" : `Need ${Math.abs(5 - selectedApps.length)} more ${Math.abs(5 - selectedApps.length) === 1 ? "app" : "apps"} to create a pack.`}</em>
</button>
</Link>
)}
<Link href="/generate">
<button>
<FiCodepen />
Generate script
</button>
</Link>
</div>
</div>
</div>
);
}
Example #2
Source File: [id].js From winstall with GNU General Public License v3.0 | 4 votes |
function PackDetail({ pack, creator, error }) {
const router = useRouter();
const { selectedApps, setSelectedApps } = useContext(SelectedContext);
const [user, setUser] = useState();
const [deleting, setDeleting] = useState(false);
const [deleteLabel, setDeleteLabel] = useState("Delete Pack");
useEffect(() => {
getSession().then(async (session) => {
if (!session) {
return;
}
setUser(session.user);
});
}, []);
const fallbackMessage = {
title: "Sorry! We could not load this pack.",
subtitle: error
? `Recieved error: ${error}`
: "Unfortunately, this pack could not be loaded. Either it does not exist, or something else went wrong. Please try again later.",
};
if (!router.isFallback && !pack) {
return <Error {...fallbackMessage} />;
}
const handleSelectAll = () => {
const updatedList = [...selectedApps, ...pack.apps];
let uniqueList = [
...new Map(updatedList.map((item) => [item["_id"], item])).values(),
];
setSelectedApps(uniqueList);
};
const handleShare = () => {
const link = `https://twitter.com/intent/tweet?text=${encodeURIComponent(
`Checkout the "${pack.title}" pack by @${creator.screen_name}!`
)}&url=${encodeURIComponent(
`https://winstall.app/packs/${pack._id}`
)}&via=winstallHQ`;
window.open(link);
};
const deletePack = async () => {
if (!user) return;
setDeleting(true);
setDeleteLabel("Deleting...");
const { response } = await fetchWinstallAPI(`/packs/${pack._id}`, {
method: "DELETE",
headers: {
Authorization: `${user.accessToken},${user.refreshToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ creator: pack.creator }),
});
if (response && response.msg) {
setDeleteLabel("Deleted!");
localStorage.removeItem("ownPacks");
router.push("/packs");
}
};
const handleDelete = async (e) => {
if (deleting) return;
if ("confirm" in window && typeof window.confirm === "function") {
if (window.confirm("Are you sure you want to delete this pack?")) {
deletePack();
}
} else {
deletePack();
}
};
return (
<PageWrapper>
<div className={styles.content}>
{router.isFallback ? (
<AppSkeleton />
) : (
<div>
<MetaTags
title={`${pack.title} - winstall`}
desc={`Includes ${pack.apps[0].name}, ${pack.apps[1].name}, ${pack.apps[2].name}, and more!`}
/>
<h1>{pack.title}</h1>
<Link
href="/users/[id]"
as={`/users/${creator.id_str}`}
prefetch={false}
>
<a
className={styles.author}
title="View other packs by this user"
>
<img
src={creator.profile_image_url_https}
alt="pack creator image"
/>
@{creator.screen_name}
</a>
</Link>
<p>{pack.desc}</p>
<p className={styles.time}>
<FiClock /> Last updated {timeAgo(pack.updatedAt)}{" "}
</p>
<div className={styles.packGet}>
<a
className="button lightText"
href="#packScript"
id={pack.accent}
>
<FiCodepen /> Get Pack
</a>
<a className="button" onClick={handleSelectAll}>
<FiPackage /> Select Apps
</a>
<a className="button" onClick={handleShare}>
<FiShare2 /> Share
</a>
</div>
{user && user.id === pack.creator && (
<div className={styles.packGet}>
<Link href={`/packs/edit?id=${pack._id}`} prefetch={false}>
<a className="button subtle">
<FiEdit /> Edit Pack
</a>
</Link>{" "}
<a className="button subtle" onClick={handleDelete}>
<FiTrash /> {deleteLabel}
</a>
</div>
)}
<PackAppsList providedApps={pack.apps} reorderEnabled={false} />
<ScriptCode apps={pack.apps} />
</div>
)}
{/* <PackAppsList providedApps={packApps} reorderEnabled={false}/> */}
</div>
</PageWrapper>
);
}
Example #3
Source File: Icon.jsx From nextjs-prismic-blog-starter with MIT License | 4 votes |
Icon = ({name, url, style}) => {
const renderIcon = () => {
switch (name) {
case 'Facebook':
return (
<GrFacebookOption
sx={{
...style,
'&:hover': {
color: '#3b5998',
},
}}
/>
)
case 'Twitter':
return (
<GrTwitter
sx={{
...style,
'&:hover': {
color: '#1da1f2',
},
}}
/>
)
case 'LinkedIn':
return (
<GrLinkedinOption
sx={{
...style,
'&:hover': {
color: '#0077b5',
},
}}
/>
)
case 'Medium':
return (
<GrMedium
sx={{
...style,
'&:hover': {
color: '#00ab6c',
},
}}
/>
)
case 'GitHub':
return (
<GrGithub
sx={{
...style,
'&:hover': {
color: '#333',
},
}}
/>
)
case 'CodePen':
return (
<FiCodepen
sx={{
...style,
'&:hover': {
color: '#ae63e4',
},
}}
/>
)
case 'Portfolio':
return (
<IoIosGlobe
sx={{
...style,
'&:hover': {
color: '#fc7740',
},
}}
/>
)
case 'WhatsApp':
return (
<IoLogoWhatsapp
sx={{
...style,
'&:hover': {
color: '#128c7e',
},
}}
/>
)
default:
return null
}
}
return (
<a
href={url}
target='_blank'
rel='noreferrer noopener'
aria-label={name}
title={name}
onClick={() =>
trackGAEvent('social icons', `clicked on ${name} link`, 'icon click')
}>
{renderIcon()}
</a>
)
}