Skip to content

Commit

Permalink
feat: add support for shared data with icon packs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Jan 24, 2024
1 parent 2418e9a commit 8ba33eb
Show file tree
Hide file tree
Showing 30 changed files with 195 additions and 32 deletions.
2 changes: 2 additions & 0 deletions apps/picsa-apps/extension-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
"input": "libs/shared-assets/svgs/crops/",
"output": "assets/budget-cards/"
},
{ "glob": "*.svg", "input": "libs/data/weather/svgs", "output": "assets/svgs/weather" },
{ "glob": "*.svg", "input": "libs/data/crop_activity/svgs", "output": "assets/svgs/crop_activity" },
{
"glob": "**/*",
"input": "apps/picsa-tools/climate-tool/src/assets",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ footer {
}

.nav-icon {
width: 70px;
width: auto;
height: 70px;
}
.nav-text {
Expand Down
1 change: 1 addition & 0 deletions apps/picsa-apps/extension-app/src/assets/svgs/farmer.svg
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.
6 changes: 1 addition & 5 deletions apps/picsa-tools/option-tool/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
"assets": [
"apps/picsa-tools/option-tool/src/favicon.ico",
"apps/picsa-tools/option-tool/src/assets",
{
"glob": "*.svg",
"input": "libs/shared-assets/svgs/weather",
"output": "assets/svgs/weather"
},
{ "glob": "*.svg", "input": "libs/data/weather/svgs", "output": "assets/svgs/weather" },
{
"glob": "*.json",
"input": "libs/i18n/assets",
Expand Down
6 changes: 1 addition & 5 deletions apps/picsa-tools/seasonal-calendar-tool/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
"assets": [
"apps/picsa-tools/seasonal-calendar-tool/src/favicon.ico",
"apps/picsa-tools/seasonal-calendar-tool/src/assets",
{
"glob": "*.svg",
"input": "libs/shared-assets/svgs/weather",
"output": "assets/svgs/weather"
},
{ "glob": "*.svg", "input": "libs/data/weather/svgs", "output": "assets/svgs/weather" },
{
"glob": "*.json",
"input": "libs/i18n/assets",
Expand Down
10 changes: 10 additions & 0 deletions libs/data/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# PICSA Data

Hardcoded data shared across tools

## Importing Icons

Corresponding icons for any data collection need to be imported into the app `project.json` file
Only import icon sets for the data used to save disk space

```json
{ "glob": "*.svg", "input": "libs/data/weather/svgs", "output": "assets/svgs/weather" },
{"glob": "*.svg", "input": "libs/data/crop_activity/svgs","output": "assets/svgs/crop_activity"},
```
60 changes: 60 additions & 0 deletions libs/data/crop_activity/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-marker';
import { IPicsaDataWithIcons } from '../models';

export const CROP_ACTIVITY_HASHMAP = {
fertiliser_apply: { label: translateMarker('Apply Fertiliser') },
land_preparation: { label: translateMarker('Land Preparation') },
sowing: { label: translateMarker('Sowing') },
watering: { label: translateMarker('Watering') },
weeding: { label: translateMarker('Weeding') },
} as const;

// Extract list of available weather names
type CropActivityName = keyof typeof CROP_ACTIVITY_HASHMAP;

// TODO - migrate budget tool to use
// TODO - organise all data in similar format and add documentation about storing/using images

export const CROP_ACTIVITY_DATA = Object.entries(CROP_ACTIVITY_HASHMAP).map(([id, { label }]) => {
const data: IPicsaDataWithIcons = {
assetIconPath: `assets/svgs/crop_activity/${id}.svg`,
label: label as string,
svgIcon: `picsa_crop_activity_${id}`,
};
return {
id: id as CropActivityName,
...data,
};
});

// TODO - should ideally migrate budget and include mapped options
/**
[ 'build-housing',
'dipping',
'feeding-livestock',
'provide-supplements',
'provide-water',
'relocation',
'transport-livestock',
'vaccinate',
'apply-fertiliser',
'apply-pesticide',
'bagging',
'banding',
'compost-manure-making',
'harvesting',
'land-clearing',
'mulching',
'ploughing',
'post-harvest-handling',
'shelling',
'sowing',
'storage',
'threshing',
'transport',
'watering',
'weeding',
'marketing-and-selling',
'value-addition',
'purchase' ]
*/
4 changes: 4 additions & 0 deletions libs/data/crop_activity/svgs/fertiliser_apply.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions libs/data/crop_activity/svgs/land_preparation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8ba33eb

Please sign in to comment.