-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
labwc: redesign based on Ghaf UI initial prototype
This aligns the system design closer to the prototypes in Figma. Adds some helper functions for PNG manipulation and SVG conversion. Signed-off-by: Humaid Alqasimi <humaid.alqassimi@tii.ae>
- Loading branch information
1 parent
7706fe0
commit b729f8b
Showing
13 changed files
with
460 additions
and
130 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,94 @@ | ||
# Copyright 2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{pkgs, ...}: rec { | ||
/* | ||
* | ||
Resizes a PNG to fit the given size. | ||
# Inputs | ||
`name` | ||
: Name of the file, this will be included in the output filename. | ||
`path` | ||
: Path of the original PNG file to be resized. | ||
`size` | ||
: The new size for the image (<height>x<width>). | ||
# Type | ||
``` | ||
resizePNG :: [String] -> [String] -> [String] -> [String] | ||
``` | ||
# Example | ||
:::{.example} | ||
## Simple example | ||
```nix | ||
resizePNG "my-icon" ./my-icon-hi-res.png "24x24"; | ||
``` | ||
::: | ||
*/ | ||
resizePNG = name: path: size: let | ||
out = pkgs.runCommand "${name}-${size}" {} '' | ||
mkdir -p $out | ||
${pkgs.buildPackages.imagemagick}/bin/convert \ | ||
${path} \ | ||
-resize ${size} \ | ||
$out/${name}.png | ||
''; | ||
in "${out}/${name}.png"; | ||
|
||
/* | ||
* | ||
Converts an SVG file to a PNG of a specific size. | ||
# Inputs | ||
`name` | ||
: Name of the file, this will be included in the output filename. | ||
`path` | ||
: Path of the original SVG file to be converted. | ||
`size` | ||
: The size of the PNG image to be rendered. | ||
# Type | ||
``` | ||
svgToPNG :: [String] -> [String] -> [String] -> [String] | ||
``` | ||
# Example | ||
:::{.example} | ||
## Simple example | ||
```nix | ||
svgToPNG "my-icon" ./my-icon.svg "24x24"; | ||
``` | ||
::: | ||
*/ | ||
svgToPNG = name: path: size: let | ||
sizes = builtins.split "x" size; | ||
width = builtins.head sizes; | ||
height = builtins.elemAt sizes 2; | ||
out = pkgs.runCommand "${name}-${size}" {} '' | ||
mkdir -p $out | ||
${pkgs.librsvg}/bin/rsvg-convert ${path} -o $out/${name}.png \ | ||
--width=${width} --height=${height} --keep-aspect-ratio | ||
''; | ||
in "${out}/${name}.png"; | ||
} |
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
Oops, something went wrong.