-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* attempt global override with compile time env value * set_tw_options OnceLock * Remove unused .cargo/config.toml * fix doc test * fix clippy error, use copied * improved docs * update readme * small readme update * remove prefix from example * example fixes * fix broken doc link * remove inline annotation
- Loading branch information
1 parent
2853fb5
commit 8f1968d
Showing
13 changed files
with
205 additions
and
132 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use std::sync::OnceLock; | ||
|
||
/// Configuration for merging Tailwind classes. | ||
/// If you want to set global options use [`set_merge_options`]. | ||
#[derive(Clone, Copy, Debug)] | ||
pub struct MergeOptions { | ||
/// Custom prefix for modifiers in Tailwind classes | ||
/// | ||
/// Default is empty string | ||
/// | ||
/// <https://tailwindcss.com/docs/configuration#prefix> | ||
pub prefix: &'static str, | ||
/// Custom separator for modifiers in Tailwind classes | ||
/// | ||
/// Default is `:` | ||
/// | ||
/// <https://tailwindcss.com/docs/configuration#separator> | ||
pub separator: &'static str, | ||
} | ||
|
||
impl Default for MergeOptions { | ||
fn default() -> Self { | ||
MERGE_OVERRIDE | ||
.get() | ||
.copied() | ||
.unwrap_or(DEFAULT_MERGE_OPTIONS) | ||
} | ||
} | ||
|
||
const DEFAULT_MERGE_OPTIONS: MergeOptions = MergeOptions { | ||
prefix: "", | ||
separator: ":", | ||
}; | ||
|
||
impl From<MergeOptions> for crate::ast::AstParseOptions<'static> { | ||
fn from(options: MergeOptions) -> Self { | ||
crate::ast::AstParseOptions { | ||
prefix: options.prefix, | ||
separator: options.separator, | ||
} | ||
} | ||
} | ||
|
||
pub(crate) static MERGE_OVERRIDE: OnceLock<MergeOptions> = OnceLock::new(); | ||
|
||
/// Set global options for merging Tailwind classes. | ||
/// Useful for getting all the macros to work with custom options. | ||
pub fn set_merge_options(options: MergeOptions) { | ||
let _ = MERGE_OVERRIDE.set(options); | ||
} |
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
Oops, something went wrong.