Skip to main content

dioxus_fluent_sysicon/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use crate::generator::Component;
4use lazy_static::lazy_static;
5use proc_macro::TokenStream;
6use syn::parse_macro_input;
7
8const SELF_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
9lazy_static! {
10  static ref CARGO: std::path::PathBuf = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
11}
12
13mod generator;
14mod parse_input;
15
16#[proc_macro]
17#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/ICON.md"))]
18pub fn use_icon(input: TokenStream) -> TokenStream {
19  let input = parse_macro_input!(input as parse_input::InputTree);
20  parse_input::generate_token_stream(input).into()
21}
22
23/// # Use this macro in icons.rs (create the module anywhere you like)
24///
25/// ## There are 5 type of identifier this macro accept as input: filled, color, light, regular and the name of the icon as fallback.
26///
27/// ### filled, color, light and regular will define icon as dioxus component based on the types
28/// ### fallback will search input as icon name and define it as component
29///
30/// # example
31/// ```no_run
32///   /// You will get AddFilled component
33///   dioxus_fluent_sysicon::define_as_component!(add_filled);
34///    /// You will get all colored type icons as component
35///    dioxus_fluent_sysicon::define_as_component!(color);
36/// ```
37#[proc_macro]
38pub fn define_as_component(input: TokenStream) -> TokenStream {
39  let comp = parse_macro_input!(input as Component);
40  generator::generate_components(comp).into()
41}