This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 💄 add option to fill social buttons
- Loading branch information
Showing
1 changed file
with
58 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,64 @@ | ||
|
||
import * as SocialButtons from '../Buttons/Social'; | ||
|
||
const SocialButtonsBuilder = (baseProps) => { | ||
const iconBaseProps = baseProps; | ||
const buttons = []; | ||
const create = (config, name, linkFn, titleFn) => { | ||
if (config && config.length > 0) { | ||
const btn = SocialButtons[name]; | ||
if (btn) { | ||
const link = linkFn(config); | ||
const title = titleFn ? titleFn(name) : `Follow on ${name}`; | ||
buttons.push(btn({link: link, key: `${name}-social`, title: title, ...iconBaseProps})) | ||
} | ||
} | ||
} | ||
const get = () => buttons; | ||
return { | ||
get: get, | ||
create: create | ||
const iconBaseProps = baseProps; | ||
const buttons = []; | ||
const create = (config, name, optConfig) => { | ||
if (config && config.length > 0) { | ||
const btn = SocialButtons[name]; | ||
if (btn) { | ||
const link = optConfig && optConfig.linkFn ? optConfig.linkFn(config) : config; | ||
const title = | ||
optConfig && optConfig.titleFn ? optConfig.titleFn(name) : `Follow on ${name}`; | ||
const additionalProps = | ||
optConfig && optConfig.additionalProps ? optConfig.additionalProps : {}; | ||
buttons.push( | ||
btn({ | ||
link: link, | ||
key: `${name}-social`, | ||
title: title, | ||
...iconBaseProps, | ||
...additionalProps, | ||
}) | ||
); | ||
} | ||
} | ||
} | ||
}; | ||
const get = () => buttons; | ||
return { | ||
get: get, | ||
create: create, | ||
}; | ||
}; | ||
|
||
export default (iconBaseProps, socialConfig) => { | ||
const buttons = SocialButtonsBuilder(iconBaseProps); | ||
buttons.create(socialConfig.facebook, 'Facebook', link => link); | ||
buttons.create(socialConfig.github, 'Github', link => link); | ||
buttons.create(socialConfig.gitlab, 'Gitlab', link => link); | ||
buttons.create(socialConfig.instagram, 'Instagram', link => link); | ||
buttons.create(socialConfig.linkedin, 'Linkedin', link => link); | ||
buttons.create(socialConfig.mail, 'Mail', address => `mailto:${address}`, name => `Send email to owner`); | ||
buttons.create(socialConfig.gmail, 'Mail', address => `https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=${address}`, name => `Send email to owner`); | ||
buttons.create(socialConfig.slack, 'Slack', link => link); | ||
buttons.create(socialConfig.twitch, 'Twitch', link => link); | ||
buttons.create(socialConfig.twitter, 'Twitter', link => link); | ||
buttons.create(socialConfig.youtube, 'Youtube', link => link); | ||
return buttons.get(); | ||
}; | ||
const buttons = SocialButtonsBuilder(iconBaseProps); | ||
buttons.create(socialConfig.facebook, 'Facebook'); | ||
buttons.create(socialConfig.github, 'Github'); | ||
buttons.create(socialConfig.gitlab, 'Gitlab'); | ||
buttons.create(socialConfig.instagram, 'Instagram'); | ||
buttons.create(socialConfig.linkedin, 'Linkedin', { | ||
additionalProps: { | ||
fill: iconBaseProps.stroke, | ||
hoverFill: iconBaseProps.hoverStroke, | ||
}, | ||
}); | ||
buttons.create(socialConfig.mail, 'Mail', { | ||
linkFn: (address) => `mailto:${address}`, | ||
titleFn: (name) => `Send email to owner`, | ||
}); | ||
buttons.create(socialConfig.gmail, 'Mail', { | ||
linkFn: (address) => `https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=${address}`, | ||
titleFn: (name) => `Send email to owner`, | ||
}); | ||
buttons.create(socialConfig.slack, 'Slack'); | ||
buttons.create(socialConfig.twitch, 'Twitch'); | ||
buttons.create(socialConfig.twitter, 'Twitter', { | ||
additionalProps: { | ||
fill: iconBaseProps.stroke, | ||
hoverFill: iconBaseProps.hoverStroke, | ||
}, | ||
}); | ||
buttons.create(socialConfig.youtube, 'Youtube'); | ||
return buttons.get(); | ||
}; |