diff --git a/Documentation/Blazorise.Docs.Server/wwwroot/img/avatars/giorgi.png b/Documentation/Blazorise.Docs.Server/wwwroot/img/avatars/giorgi.png new file mode 100644 index 0000000000..35d847755f Binary files /dev/null and b/Documentation/Blazorise.Docs.Server/wwwroot/img/avatars/giorgi.png differ diff --git a/Documentation/Blazorise.Docs.Server/wwwroot/img/blog/2024-05-17/how-to-create-social-media-share-buttons.png b/Documentation/Blazorise.Docs.Server/wwwroot/img/blog/2024-05-17/how-to-create-social-media-share-buttons.png new file mode 100644 index 0000000000..840a83bd5e Binary files /dev/null and b/Documentation/Blazorise.Docs.Server/wwwroot/img/blog/2024-05-17/how-to-create-social-media-share-buttons.png differ diff --git a/Documentation/Blazorise.Docs.Server/wwwroot/img/blog/2024-05-17/share-buttons.png b/Documentation/Blazorise.Docs.Server/wwwroot/img/blog/2024-05-17/share-buttons.png new file mode 100644 index 0000000000..74a53c6248 Binary files /dev/null and b/Documentation/Blazorise.Docs.Server/wwwroot/img/blog/2024-05-17/share-buttons.png differ diff --git a/Documentation/Blazorise.Docs/Pages/Blog/2024-06-12_HowToCreateSocialMediaShareButtons/Code/HowToCreateSocialMediaShareButtons_BrandsCode.html b/Documentation/Blazorise.Docs/Pages/Blog/2024-06-12_HowToCreateSocialMediaShareButtons/Code/HowToCreateSocialMediaShareButtons_BrandsCode.html new file mode 100644 index 0000000000..f895096f0b --- /dev/null +++ b/Documentation/Blazorise.Docs/Pages/Blog/2024-06-12_HowToCreateSocialMediaShareButtons/Code/HowToCreateSocialMediaShareButtons_BrandsCode.html @@ -0,0 +1,20 @@ +
+.bg-x { + background-color: #000000 !important; +} + +.bg-discord { + background-color: #5865F2 !important; +} + +.bg-github { + background-color: #0D1117 !important; +} + +/* + * other brand colors... add the brands you need here! + * IMPORTANT NOTE: please make sure, you prefix your class names with `bg-` + */ +
+<html> +<head> + <link href="_content/Blazorise.Icons.FontAwesome/v6/css/all.min.css" rel="stylesheet"> + ... +</head> +... +</html> +
+<html> +<head> + <link href="brands.css" rel="stylesheet" /> + ... +</head> +</html> +
+public record Platform(string Name, string TextColor, string BackgroundColor, string IconName, string Href) +{ + public static Platform X => new Platform("X", "white", "x", "fa-brands fa-x", "https://twitter.com/intent/tweet"); + + // your social media platform can go here. +} +
+@code +{ + [Parameter, EditorRequired] + public Platform Platform { get; set; } + + [Parameter] + public Size ButtonSize { get; set; } = Size.Large; + + [Parameter, EditorRequired] + public RenderFragment ChildContent { get; set; } + + [Parameter(CaptureUnmatchedValues = true)] + public Dictionary<string, object> AdditionalAttributes { get; set; } = new(); +} +
+<Button TextColor="@Platform.TextColor" + Background="@(new Background(Platform.BackgroundColor))" + To="@Platform.Href" + Type="@ButtonType.Link" + Size="" + @attributes=""> + + @ChildContent + + <Icon Name="@($"fa-brands {Platform.IconName}")" IconStyle="IconStyle.Light"/> +</Button> +
+<ShareButton Brand="@Platform.X"> + Share on +</ShareButton> +
Platform.cs
. We will use a record for this. Choosing the right tool to solve our problems is always a good idea. I think records are ideal for this scenario as they are basically immutable data classes, ie. unchangeable collections of values. You can read more about them /Components/
folder. This folder is a great place for keeping components which are reused in many different places across your app!
+ShareButtonComponent.razor
, and write the following in it:
+Platform
- The platform of the share button. The user will pass the platforms which will are statically defined inside the Platform record.
+ Size
- The size of the button, this is a Blazorise class, so we can use Small, Medium, Large etc.
+ ChildContent
- The markup displayed inside the button. See AdditionalAttributes
- Any additional attributes the user passes to the button. Will directly be applied to the underlying button component. See [Parameter]
attribute!
+[EditorRequired]
does, well, it is a really useful attribute. It marks a regular Parameter required, meaning that we will see warnings in our IDE when we don't pass the required parameters to our component. This is extremely useful to prevent accidental bugs while writing Blazor components. Because Blazor components are strongly typed, there is little to no room for making mistakes while using them.
+/wwwroot/
folder. Let's name it brands.css
. This CSS file will hold all of our brand colors. Here are some example colors, which you may expand further as you need to add more brands!
++ Note: The+!important
property, this is necessary as, by default the Bootstrap icons will have theColor
property set toprimary
, this will shadow our custom background colors, so adding!important
at the end of them will fix this. +
wwwroot/index.html
+Index.razor
add your component like so:
++ Note: Notice how the text inside the button says+Share on
instead ofShare on X
, this is because X's logo is literally the latin letter X, so it would not make sense, so haveShare on X ✖
+
+ Also, try to omit the Brand parameter, or the ChildContent - which in this case is just the text "Share on". You will see warnings in your code, your IDE will warn you about not passing required parameters to your component. ++