Skip to content

Commit

Permalink
Merge pull request #10 from osu-wams/update-icon-list
Browse files Browse the repository at this point in the history
Update icon list
  • Loading branch information
emerham authored Aug 6, 2024
2 parents 4ee0102 + 58c0f74 commit 57ed37c
Show file tree
Hide file tree
Showing 11 changed files with 3,001 additions and 5,279 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,27 @@ To continuously compile \
npm run watch
```

## Icon Name updates

### OSU Icon Names

To Generate a new list of OSU Icons, replace osu-icon-url with the latest url.

```shell
npm run generate-icons osu-icon-url
```

### FA Icons

There are two lists of FA icons we need to generate, the normal solid ones and the branded ones. Replace the
`<version>` with the appropriate version to generate for both.

```shell
npm run generate-fa-icons https://cdnjs.cloudflare.com/ajax/libs/font-awesome/<version>/css/fontawesome.min.css
```

```shell
npm run generate-fa-icons https://cdnjs.cloudflare.com/ajax/libs/font-awesome/<version>/css/brands.min.css
```

Copy the results into the respective arrays in [icon-list.js](js/icon-list.js)
353 changes: 187 additions & 166 deletions composer.lock

Large diffs are not rendered by default.

102 changes: 58 additions & 44 deletions js/bundle.js

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions js/generate-fa-icon-names.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import fetch from "node-fetch"

const cliArguments = process.argv.slice();
const iconUrl = cliArguments.slice(2);

/**
* Parse the CSS
* @param faIconUrl
* @returns {Promise<RegExpMatchArray>}
*/
async function getOsuIconNames(faIconUrl) {
var iconNames = [];
var response = await fetch(faIconUrl, {
headers: {
'Access-Control-Allow-Origin': '*'
},
});
var data = await response.text();

// parse css to get icon names
iconNames = data.match(/\.fa-[a-zA-Z0-9_-]*:/g);
// trim css class names down to just the icon names
iconNames.forEach((name, i) => {
iconNames[i] = name.replace('.fa-', "").slice(0, -1);
});

return iconNames;
}

const osuIconList = await getOsuIconNames(iconUrl[0]);
osuIconList.sort();
osuIconList.forEach(iconName => {
console.log(`'${iconName}',`);
});
Loading

0 comments on commit 57ed37c

Please sign in to comment.