mac-human-design 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/package.json +59 -0
- package/src/components/AppWindowShell.tsx +25 -0
- package/src/components/MacSegmentedControl.tsx +54 -0
- package/src/components/StatusMessage.tsx +52 -0
- package/src/components/SymbolIconButton.tsx +138 -0
- package/src/components/ViewDragRegion.tsx +18 -0
- package/src/components/index.ts +5 -0
- package/src/index.ts +18 -0
- package/src/symbols/SystemSymbolImage.tsx +72 -0
- package/src/symbols/index.ts +9 -0
- package/src/symbols/systemSymbolService.ts +68 -0
- package/src/symbols/useSystemSymbol.ts +75 -0
- package/src/tauri/index.ts +4 -0
- package/src/theme/index.ts +1 -0
- package/src/theme/macosTheme.ts +570 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/isDraggableAreaTarget.ts +22 -0
- package/src-tauri/Cargo.toml +21 -0
- package/src-tauri/src/lib.rs +10 -0
- package/src-tauri/src/system_symbols.rs +66 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
use tauri::plugin::{Builder, TauriPlugin};
|
|
2
|
+
|
|
3
|
+
mod system_symbols;
|
|
4
|
+
|
|
5
|
+
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
6
|
+
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
|
|
7
|
+
Builder::new("human-design-system-symbols")
|
|
8
|
+
.invoke_handler(tauri::generate_handler![system_symbols::system_symbol_png_data_url])
|
|
9
|
+
.build()
|
|
10
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#[cfg(target_os = "macos")]
|
|
2
|
+
use base64::{engine::general_purpose, Engine as _};
|
|
3
|
+
|
|
4
|
+
#[cfg(target_os = "macos")]
|
|
5
|
+
use objc2_app_kit::{
|
|
6
|
+
NSBitmapImageFileType, NSBitmapImageRep, NSBitmapImageRepPropertyKey, NSFontWeightMedium,
|
|
7
|
+
NSImage, NSImageSymbolConfiguration, NSImageSymbolScale,
|
|
8
|
+
};
|
|
9
|
+
#[cfg(target_os = "macos")]
|
|
10
|
+
use objc2_foundation::{NSDictionary, NSString};
|
|
11
|
+
|
|
12
|
+
#[cfg(target_os = "macos")]
|
|
13
|
+
#[tauri::command]
|
|
14
|
+
pub fn system_symbol_png_data_url(
|
|
15
|
+
name: String,
|
|
16
|
+
point_size: Option<f64>,
|
|
17
|
+
) -> Result<Option<String>, String> {
|
|
18
|
+
let resolved_point_size = point_size.unwrap_or(18.0).clamp(10.0, 256.0);
|
|
19
|
+
|
|
20
|
+
let symbol_name = NSString::from_str(&name);
|
|
21
|
+
let description = NSString::from_str(&name);
|
|
22
|
+
|
|
23
|
+
let Some(symbol_image) =
|
|
24
|
+
NSImage::imageWithSystemSymbolName_accessibilityDescription(&symbol_name, Some(&description))
|
|
25
|
+
else {
|
|
26
|
+
return Ok(None);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let point_size_configuration =
|
|
30
|
+
NSImageSymbolConfiguration::configurationWithPointSize_weight_scale(
|
|
31
|
+
resolved_point_size,
|
|
32
|
+
unsafe { NSFontWeightMedium },
|
|
33
|
+
NSImageSymbolScale::Large,
|
|
34
|
+
);
|
|
35
|
+
let monochrome_configuration = NSImageSymbolConfiguration::configurationPreferringMonochrome();
|
|
36
|
+
let configuration =
|
|
37
|
+
point_size_configuration.configurationByApplyingConfiguration(&monochrome_configuration);
|
|
38
|
+
let image = symbol_image
|
|
39
|
+
.imageWithSymbolConfiguration(&configuration)
|
|
40
|
+
.unwrap_or(symbol_image);
|
|
41
|
+
|
|
42
|
+
let Some(tiff_data) = image.TIFFRepresentation() else {
|
|
43
|
+
return Ok(None);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
let Some(bitmap) = NSBitmapImageRep::imageRepWithData(&tiff_data) else {
|
|
47
|
+
return Ok(None);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
let properties = NSDictionary::<NSBitmapImageRepPropertyKey, objc2::runtime::AnyObject>::new();
|
|
51
|
+
let png_data = unsafe {
|
|
52
|
+
bitmap.representationUsingType_properties(NSBitmapImageFileType::PNG, &properties)
|
|
53
|
+
}
|
|
54
|
+
.ok_or_else(|| format!("Failed to render SF Symbol '{name}' as PNG."))?;
|
|
55
|
+
|
|
56
|
+
Ok(Some(format!(
|
|
57
|
+
"data:image/png;base64,{}",
|
|
58
|
+
general_purpose::STANDARD.encode(png_data.to_vec())
|
|
59
|
+
)))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[cfg(not(target_os = "macos"))]
|
|
63
|
+
#[tauri::command]
|
|
64
|
+
pub fn system_symbol_png_data_url(_name: String, _point_size: Option<f64>) -> Result<Option<String>, String> {
|
|
65
|
+
Ok(None)
|
|
66
|
+
}
|