Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
feat: add correct icons and icon sizes to wio dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Raspincel committed Dec 14, 2023
1 parent f8333a3 commit 8f8d345
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"yargs": "^17.7.2"
},
"dependencies": {
"@superviz/sv-icons": "^0.8.8",
"ably": "^1.2.45",
"bowser": "^2.11.0",
"bowser-jr": "^1.0.6",
Expand Down
2 changes: 1 addition & 1 deletion src/common/styles/global.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import url('https://unpkg.com/@superviz/sv-icons@0.8.7/css/style.css');
@import url('https://unpkg.com/@superviz/sv-icons@0.8.10/css/style.css');
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap');

html, body {
Expand Down
4 changes: 0 additions & 4 deletions src/web-components/dropdown/index.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ export const dropdownStyle = css`
position: relative;
}
.dropdown-list * {
box-sizing: border-box;
}
.header {
display: flex;
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion src/web-components/dropdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export class Dropdown extends WebComponentsBaseElement {
};

const icons = this.icons?.map((icon) => {
return html`<superviz-icon name="${icon}" size="sm"></superviz-icon>`;
return html`<superviz-icon allowSetSize=${true} name="${icon}" size="sm"></superviz-icon>`;
});

const options = this.options.map((option, index) => {
Expand Down
16 changes: 15 additions & 1 deletion src/web-components/icon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { customElement } from 'lit/decorators.js';

import { WebComponentsBase } from '../base';

import { IconSizes } from './types';

const WebComponentsBaseElement = WebComponentsBase(LitElement);
const styles: CSSResultGroup[] = [WebComponentsBaseElement.styles];

@customElement('superviz-icon')
export class Icon extends WebComponentsBaseElement {
declare name: string;
declare size: string;
declare allowSetSize: boolean;

constructor() {
super();
Expand All @@ -21,8 +24,14 @@ export class Icon extends WebComponentsBaseElement {
static properties = {
name: { type: String },
size: { type: String },
allowSetSize: { type: Boolean },
};

private get iconSize(): string {
if (!this.allowSetSize) return;
return IconSizes[this.size];
}

static styles = [
styles,
css`
Expand All @@ -39,6 +48,11 @@ export class Icon extends WebComponentsBaseElement {
];

protected render() {
return html` <i class="sv-icon sv-icon-${this.name}_${this.size}"></i> `;
return html`
<i
class="sv-icon sv-icon-${this.name}_${this.size}"
style="font-size: ${this.iconSize}px"
></i>
`;
}
}
7 changes: 7 additions & 0 deletions src/web-components/icon/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum IconSizes {
xs = 14,
sm = 20,
md = 24,
lg = 36,
xl = 44,
}
4 changes: 0 additions & 4 deletions src/web-components/who-is-online/css/dropdown.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ export const dropdownStyle = css`
flex-direction: column;
}
.dropdown-list * {
box-sizing: border-box;
}
.dropdown-list > div {
padding: 4px;
min-width: 216px;
Expand Down
2 changes: 1 addition & 1 deletion src/web-components/who-is-online/who-is-online.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class WhoIsOnline extends WebComponentsBaseElement {
}

private getIcons(isLocal: boolean, isBeingFollowed: boolean) {
return isLocal ? ['help', 'eye_inative'] : ['place', isBeingFollowed ? 'send-off' : 'send'];
return isLocal ? ['gather', 'eye_inative'] : ['place', isBeingFollowed ? 'send-off' : 'send'];
}

private putLocalParticipationFirst() {
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2469,11 +2469,6 @@
dependencies:
"@sinonjs/commons" "^3.0.0"

"@superviz/sv-icons@^0.8.8":
version "0.8.8"
resolved "https://registry.yarnpkg.com/@superviz/sv-icons/-/sv-icons-0.8.8.tgz#702ff1f2dd6bd89bb9b82953ec05c60ee2037119"
integrity sha512-+X5yqHSriKNlCdJq6b2j0xRuOYl9gCGXSG58t7HMZ1Vm4bxYgNxkfWjz6HmWNnotsQh/mBktE5J00KZK3jP2Gg==

"@szmarczak/http-timer@^4.0.5":
version "4.0.6"
resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz"
Expand Down

0 comments on commit 8f8d345

Please sign in to comment.