use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::error::Error; use std::fs; use std::fs::File; use std::io::Read; use std::io::Write; use std::path::Path; use std::path::PathBuf; #[derive(Serialize, Deserialize)] pub struct BrandConfig { pub default_separator: String, pub typography_h1: String, pub typography_h2: String, pub typography_h3: String, pub typography_h4: String, pub typography_h5: String, pub typography_h6: String, pub typography_p: String, pub input_base: String, pub label_base: String, pub textarea_base: String, pub textarea_disabled: String, pub alert_success: String, pub alert_warning: String, pub alert_error: String, pub alert_info: String, pub alert_base: String, pub avatar_small: String, pub avatar_medium: String, pub avatar_large: String, pub avatar_base: String, pub badge_success: String, pub badge_warning: String, pub badge_error: String, pub badge_info: String, pub badge_default: String, pub badge_base: String, pub breadcrumb_nav: String, pub breadcrumb_list: String, pub breadcrumb_item: String, pub breadcrumb_separator: String, pub button_primary: String, pub button_secondary: String, pub button_danger: String, pub button_default: String, pub button_success: String, pub button_warning: String, pub button_ghost: String, pub button_base: String, pub button_small: String, pub button_medium: String, pub button_large: String, pub calendar_container: String, pub calendar_wrapper: String, pub calendar_header: String, pub calendar_title: String, pub calendar_month_year: String, pub calendar_nav: String, pub calendar_nav_button: String, pub calendar_grid: String, pub calendar_thead: String, pub calendar_weekdays: String, pub calendar_weekday: String, pub calendar_tbody: String, pub calendar_week: String, pub calendar_day: String, pub calendar_day_button: String, pub calendar_day_today: String, pub calendar_day_selected: String, pub calendar_day_outside: String, pub carousel_container: String, pub carousel_inner: String, pub carousel_item: String, pub carousel_item_active: String, pub carousel_controls: String, pub card_container: String, pub card_header: String, pub card_title: String, pub card_body: String, pub checkbox_base: String, pub checkbox_checked: String, pub checkbox_unchecked: String, pub checkbox_disabled: String, pub checkbox_label: String, pub col_container: String, pub collapsible_container: String, pub collapsible_header: String, pub collapsible_title: String, pub collapsible_button: String, pub collapsible_content: String, pub collapsible_item: String, pub combobox_button: String, pub combobox_button_open: String, pub combobox_button_disabled: String, pub combobox_list: String, pub combobox_item: String, pub combobox_item_selected: String, pub command_container: String, pub command_input_wrapper: String, pub command_icon: String, pub command_input: String, pub command_list: String, pub command_item: String, pub command_selected_item: String, pub command_item_icon: String, pub pagination_container: String, pub pagination_list: String, pub pagination_item_current: String, pub pagination_item: String, pub popover_container: String, pub popover_trigger: String, pub popover_content: String, pub popover_position_north_start: String, pub popover_position_north_middle: String, pub popover_position_north_end: String, pub popover_position_south_start: String, pub popover_position_south_middle: String, pub popover_position_south_end: String, pub popover_position_east_start: String, pub popover_position_east_middle: String, pub popover_position_east_end: String, pub popover_position_west_start: String, pub popover_position_west_middle: String, pub popover_position_west_end: String, pub dropdown_content: String, pub dropdown_item: String, pub dropdown_item_icon: String, pub dropdown_item_disabled: String, pub dropdown_item_widget: String, pub dropdown_separator: String, pub drawer_provider: String, pub drawer_container: String, pub drawer_header: String, pub drawer_title: String, pub drawer_description: String, pub drawer_footer: String, pub drawer_right: String, pub drawer_top: String, pub drawer_bottom: String, pub drawer_left: String, pub dialog_container: String, pub dialog_content: String, pub dialog_header: String, pub dialog_title: String, pub dialog_description: String, pub dialog_footer: String, pub notification_container: String, pub notification_content: String, pub notification_title: String, pub notification_description: String, pub notification_timestamp: String, pub notification_close_button: String, pub notification_close_icon: String, pub notification_action_container: String, pub notification_list_container: String, pub toggle_container: String, pub toggle_base: String, pub toggle_checked: String, pub toggle_unchecked: String, pub toggle_disabled: String, pub toggle_label: String, pub toggle_icon: String, pub switch_base: String, pub switch_checked: String, pub switch_unchecked: String, pub switch_disabled: String, pub switch_label: String, pub switch_thumb: String, pub switch_translate_checked: String, pub switch_translate_unchecked: String, pub select_container: String, pub select_trigger: String, pub select_trigger_placeholder: String, pub select_trigger_icon: String, pub select_content_container: String, pub select_content_list: String, pub select_group: String, pub select_label: String, pub select_item: String, pub table_container: String, pub table: String, pub table_head: String, pub table_row: String, pub table_head_row: String, pub table_cell: String, pub table_body: String, pub table_footer: String, pub tabs_container: String, pub tabs_list: String, pub tabs_list_column: String, pub tabs_list_row: String, pub tabs_trigger: String, pub tabs_trigger_inactive: String, pub tabs_trigger_active: String, pub tabs_trigger_disabled: String, pub tabs_content: String, pub group_button_container: String, pub group_button_list: String, pub group_button_trigger: String, pub group_button_trigger_active: String, pub group_button_trigger_inactive: String, pub group_button_demo: String, pub accordion_container: String, pub accordion_header: String, pub accordion_title: String, pub accordion_content: String, pub container_padding_x: String, pub container_padding_y: String, pub container_expanding: String, pub container_small: String, pub container_narrow: String, pub container_large: String, pub container_responsive: String, pub content_with_aside: String, pub content_aside: String, pub content_aside_container: String, pub page_header_container: String, pub page_header_title: String, pub page_header_actions: String, pub placeholder_container: String, pub placeholder_svg: String, pub placeholder_text: String, pub resizable_container: String, pub resizable_box: String, pub resizable_handle_visible: String, pub resizable_handle_hidden: String, pub resizable_handle_nw: String, pub resizable_handle_ne: String, pub resizable_handle_sw: String, pub resizable_handle_se: String, pub resizable_handle_n: String, pub resizable_handle_s: String, pub resizable_handle_w: String, pub resizable_handle_e: String, pub selectable_indicator: String, pub selectable_hover: String, pub selectable_selected: String, pub selectable_cursor: String, pub tag_input_container: String, pub tag_input_tags_container: String, pub tag_input_tag: String, pub tag_input_remove_button: String, pub tag_input_input: String, pub tag_input_candidates_container: String, pub tag_input_candidate_button: String, pub tailwind_color_picker_container: String, pub tailwind_color_picker_button: String, pub tailwind_color_picker_selected_color: String, pub tailwind_color_picker_dropdown: String, pub tailwind_color_picker_row: String, pub tailwind_color_picker_cell: String, } macro_rules! write_fields { ($self:expr, $f:expr, $($field:ident),+) => { $( writeln!($f, " {}: ClassesContainer::<&'static str> {{ value: \"{}\" }},", stringify!($field), $self.$field)?; )+ }; } impl BrandConfig { pub fn write_config_to_file(self, filename: &PathBuf) -> Result<(), Box> { let mut f = File::create(filename)?; writeln!( f, "pub const BRANDGUIDE: BrandGuide::<&'static str> = BrandGuide::<&'static str> {{" )?; write_fields!( self, f, default_separator, typography_h1, typography_h2, typography_h3, typography_h4, typography_h5, typography_h6, typography_p, input_base, label_base, textarea_base, textarea_disabled, alert_success, alert_warning, alert_error, alert_info, alert_base, avatar_small, avatar_medium, avatar_large, avatar_base, badge_success, badge_warning, badge_error, badge_info, badge_default, badge_base, breadcrumb_nav, breadcrumb_list, breadcrumb_item, breadcrumb_separator, button_primary, button_secondary, button_danger, button_default, button_success, button_warning, button_ghost, button_base, button_small, button_medium, button_large, calendar_container, calendar_wrapper, calendar_header, calendar_title, calendar_month_year, calendar_nav, calendar_nav_button, calendar_grid, calendar_thead, calendar_weekdays, calendar_weekday, calendar_tbody, calendar_week, calendar_day, calendar_day_button, calendar_day_today, calendar_day_selected, calendar_day_outside, carousel_container, carousel_inner, carousel_item, carousel_item_active, carousel_controls, card_container, card_header, card_title, card_body, checkbox_base, checkbox_checked, checkbox_unchecked, checkbox_disabled, checkbox_label, collapsible_container, collapsible_header, collapsible_title, collapsible_button, collapsible_content, collapsible_item, col_container, combobox_button, combobox_button_open, combobox_button_disabled, combobox_list, combobox_item, combobox_item_selected, command_container, command_input_wrapper, command_icon, command_input, command_list, command_item, command_selected_item, command_item_icon, pagination_container, pagination_list, pagination_item, pagination_item_current, popover_container, popover_trigger, popover_content, popover_position_north_start, popover_position_north_middle, popover_position_north_end, popover_position_south_start, popover_position_south_middle, popover_position_south_end, popover_position_east_start, popover_position_east_middle, popover_position_east_end, popover_position_west_start, popover_position_west_middle, popover_position_west_end, dropdown_content, dropdown_item, dropdown_item_icon, dropdown_item_disabled, dropdown_item_widget, dropdown_separator, drawer_provider, drawer_container, drawer_header, drawer_title, drawer_description, drawer_footer, drawer_right, drawer_top, drawer_bottom, drawer_left, dialog_container, dialog_content, dialog_header, dialog_title, dialog_description, dialog_footer, notification_container, notification_content, notification_title, notification_description, notification_timestamp, notification_close_button, notification_close_icon, notification_action_container, notification_list_container, toggle_container, toggle_base, toggle_checked, toggle_unchecked, toggle_disabled, toggle_label, toggle_icon, switch_base, switch_checked, switch_unchecked, switch_disabled, switch_label, switch_thumb, switch_translate_checked, switch_translate_unchecked, select_container, select_trigger, select_trigger_placeholder, select_trigger_icon, select_content_container, select_content_list, select_group, select_label, select_item, table_container, table, table_head, table_row, table_head_row, table_cell, table_body, table_footer, tabs_container, tabs_list, tabs_list_column, tabs_list_row, tabs_trigger, tabs_trigger_inactive, tabs_trigger_active, tabs_trigger_disabled, tabs_content, group_button_container, group_button_list, group_button_trigger, group_button_trigger_active, group_button_trigger_inactive, group_button_demo, accordion_container, accordion_header, accordion_title, accordion_content, container_padding_x, container_padding_y, container_expanding, container_small, container_narrow, container_large, container_responsive, content_with_aside, content_aside, content_aside_container, page_header_container, page_header_title, page_header_actions, placeholder_container, placeholder_svg, placeholder_text, resizable_container, resizable_box, resizable_handle_visible, resizable_handle_hidden, resizable_handle_nw, resizable_handle_ne, resizable_handle_sw, resizable_handle_se, resizable_handle_n, resizable_handle_s, resizable_handle_w, resizable_handle_e, selectable_indicator, selectable_hover, selectable_selected, selectable_cursor, tag_input_container, tag_input_tags_container, tag_input_tag, tag_input_remove_button, tag_input_input, tag_input_candidates_container, tag_input_candidate_button, tailwind_color_picker_container, tailwind_color_picker_button, tailwind_color_picker_selected_color, tailwind_color_picker_dropdown, tailwind_color_picker_row, tailwind_color_picker_cell ); writeln!(f, " }};")?; Ok(()) } }