Skip to content

Commit

Permalink
feat: add drawable's fillColor, strokeColor option
Browse files Browse the repository at this point in the history
  • Loading branch information
junghyeonsu committed Nov 7, 2024
1 parent 4c14fbd commit 301d2d2
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @icona/generator

## 0.9.1

### Patch Changes

- feat: add drawable's fillColor, strokeColor option
- Updated dependencies
- @icona/types@0.9.1

## 0.9.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@icona/generator",
"version": "0.9.0",
"version": "0.9.1",
"repository": {
"type": "git",
"url": "git+https://github.com/daangn/icona.git",
Expand All @@ -25,7 +25,7 @@
"prepack": "yarn build"
},
"dependencies": {
"@icona/types": "^0.9.0",
"@icona/types": "^0.9.1",
"@svgr/core": "^8.0.0",
"@types/cli-progress": "^3.11.5",
"cli-progress": "^3.12.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/generator/src/core/drawable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const generateDrawable = async (props: Props) => {
const targetPath = getTargetPath(config.path || "drawable");
const drawableConfig = config.svg2vectordrawableConfig || {};
const defaultColor = config.defaultColor;
const fillColor = config.fillColor;

if (!icons) {
throw new Error("There is no icons data");
Expand Down Expand Up @@ -61,6 +62,19 @@ export const generateDrawable = async (props: Props) => {
drawable = drawable.replace(/#FF212124/g, defaultColor);
}

// NOTE(@junghyeonsu): android:fillColor="something" 인거를 ""사이에 있는 값을 변경하기
if (fillColor) {
drawable = drawable.replace(
/android:fillColor="[^"]*"/g,
`android:fillColor="${fillColor}"`,
);

drawable = drawable.replace(
/android:strokeColor="[^"]*"/g,
`android:strokeColor="${fillColor}"`,
);
}

await writeFile(drawablePath, drawable);
bar.increment();
}
Expand Down
6 changes: 6 additions & 0 deletions packages/types/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @icona/types

## 0.9.1

### Patch Changes

- feat: add drawable's fillColor, strokeColor option

## 0.9.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@icona/types",
"version": "0.9.0",
"version": "0.9.1",
"repository": {
"type": "git",
"url": "git+https://github.com/daangn/icona.git",
Expand Down
3 changes: 3 additions & 0 deletions packages/types/src/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ export interface DrawableConfig extends BaseConfig {
* drawable default color is #FF212124
* if you want to change default color, you can use this option
* @default #FF212124
* @deprecated
*/
defaultColor?: string;

fillColor?: string;
}

export interface PNGConfig extends BaseConfig {}
Expand Down
5 changes: 3 additions & 2 deletions test/icona.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ const pdfConfig: PDFConfig = {
};

const drawableConfig: DrawableConfig = {
active: false,
active: true,
path: "drawable",
svg2vectordrawableConfig: {},
defaultColor: "@color/gray900",
// defaultColor: "@color/gray900",
// fillColor: "@color/gray900",
};

const reactConfig: ReactConfig = {
Expand Down

0 comments on commit 301d2d2

Please sign in to comment.