Skip to content

Commit

Permalink
Update custom-folder extension
Browse files Browse the repository at this point in the history
- chore: metadata update
- chore: re-installed utils
- chore: command description
- feat: create form update
- feat(wip): changelog & readme
- feat(wip): result & replace action
- feat(wip): replaceIcon script
- chore: verifications
- Merge pull request raycast#1 from Ph-lo/feat-image-shades
- feat: image shades option
- feat(wip): image shades
- chore: metadata size & lint
- chore: package.json
- chore: package.json categories
- chore: package.json owner
- chore: organization handle set in package.json
- fix: result view file name
- feat: initial commit
  • Loading branch information
Ph-lo committed Aug 25, 2024
1 parent cc1bffe commit dfff8b2
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 37 deletions.
7 changes: 5 additions & 2 deletions extensions/custom-folder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Custom Folder Changelog
# Custom folder Changelog

## [Feat Easily apply the custom icon] - 2024-08-25
- Added the ability to easily apply the new custom icon to a target folder.

## [Feat Image shades ] - 2024-08-05
- Added optional toggle - shading effect on the image, switching between a filled mask and shaded tones.

## [Initial Version] - 2023-12-16
- Custom folder extension
- Custom folder extension
15 changes: 11 additions & 4 deletions extensions/custom-folder/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Custom Folder
# Custom folder

Create custom MacOS folder images.
Customize MacOs folder icons.

![custom-folder-1](metadata/custom-folder-1.png)
![custom-folder-2](metadata/custom-folder-2.png)
## Features
- Create custom folder images.
- Apply custom folder images to a target folder.

## Options
- `Target path` - The path to the folder you want to apply the custom image to.
- `Ouput path` - The path to save the custom folder image (default is `Image path`).
- `Padding` - The padding around the image.
- `Shades` - Apply a shading effect to the image to keep shaded tones.
Binary file modified extensions/custom-folder/assets/custom-folder-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified extensions/custom-folder/assets/default-folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified extensions/custom-folder/metadata/custom-folder-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified extensions/custom-folder/metadata/custom-folder-2.png
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.
98 changes: 87 additions & 11 deletions extensions/custom-folder/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions extensions/custom-folder/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "https://www.raycast.com/schemas/extension.json",
"name": "custom-folder",
"title": "Custom Folder",
"description": "Create custom MacOS folder images.",
"title": "Custom folder",
"description": "Customize MacOS folder icons.",
"icon": "custom-folder-icon.png",
"author": "phlo",
"categories": [
Expand All @@ -13,13 +13,14 @@
"commands": [
{
"name": "index",
"title": "Create Folder Image",
"description": "Create a custom folder image.",
"title": "Customize folder",
"description": "Create a custom folder image. Allows to save or directly apply.",
"mode": "view"
}
],
"dependencies": {
"@raycast/api": "^1.64.3",
"@raycast/utils": "^1.16.5",
"jimp": "^0.22.10",
"sharp": "^0.33.0"
},
Expand Down
9 changes: 9 additions & 0 deletions extensions/custom-folder/src/createForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function CreateForm() {
imagePath: undefined,
outputPath: undefined,
});

const { push } = useNavigation();
function handleSubmit(values: FolderForm) {
const file = values.file[0];
Expand Down Expand Up @@ -71,6 +72,14 @@ export default function CreateForm() {
dropPathErrorIfNeeded(event?.target?.value?.[0] || "");
}}
/>
<Form.FilePicker
id="targetFolderPath"
title="Target path"
allowMultipleSelection={false}
canChooseDirectories
canChooseFiles={false}
info={"Optional path to the folder you want to customize."}
/>
<Form.FilePicker
id="output"
title="Output path"
Expand Down
41 changes: 41 additions & 0 deletions extensions/custom-folder/src/replaceAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Action, popToRoot } from "@raycast/api";
import { useExec } from "@raycast/utils";
import { FC, useEffect, useState } from "react";
import { replaceIconScript } from "./utils/replaceIconScript";

interface ReplaceActionProps {
iconPath: string;
targetFolderPath: string;
onAction: () => Promise<void>;
}

export const ReplaceAction: FC<ReplaceActionProps> = ({ iconPath, targetFolderPath, onAction }) => {
const [shouldExec, setShouldExec] = useState<boolean>(false);
const scriptContent = replaceIconScript(iconPath, targetFolderPath);

const { error } = useExec(`${scriptContent}`, {
shell: true,
execute: shouldExec || false,
failureToastOptions: {
title: "Failed to apply icon",
message: "Please try again, or save the icon and apply manually.",
},
onData: () => popToRoot(),
});

useEffect(() => {
// console.error("error: ", error);
}, [error]);

return (
<Action
title={"Apply to Folder"}
icon={"switch-16"}
onAction={() => {
onAction().then(() => {
setShouldExec(true);
});
}}
/>
);
};
Loading

0 comments on commit dfff8b2

Please sign in to comment.