mirror of
https://github.com/nostalgic-css/NES.css.git
synced 2025-08-22 22:02:48 +02:00
feat(avatars): add avatar component (#156)
This commit is contained in:
committed by
Abdullah Samman
parent
73b3616472
commit
3d41fb82c2
20
docs/avatars.stories.js
Normal file
20
docs/avatars.stories.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { storiesOf } from '@storybook/html'; // eslint-disable-line import/no-extraneous-dependencies
|
||||
import { // eslint-disable-line import/no-extraneous-dependencies
|
||||
withKnobs, radios, boolean,
|
||||
} from '@storybook/addon-knobs';
|
||||
|
||||
const stories = storiesOf('Avatars', module);
|
||||
stories.addDecorator(withKnobs);
|
||||
|
||||
stories.add('avatars', () => {
|
||||
const options = radios('class', {
|
||||
'is-small': 'is-small',
|
||||
default: '',
|
||||
'is-medium': 'is-medium',
|
||||
'is-large': 'is-large',
|
||||
}, '');
|
||||
const isRounded = boolean('is-rounded', false) ? 'is-rounded' : '';
|
||||
const selectedClasses = [isRounded, options].join(' ');
|
||||
|
||||
return `<img src="http://www.gravatar.com/avatar" class="nes-avatar ${selectedClasses}">`;
|
||||
});
|
14
index.html
14
index.html
@@ -94,6 +94,20 @@
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<section class="nes-container with-title">
|
||||
<h2 class="title">Avatars</h2>
|
||||
<div>
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar is-small">
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar">
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar is-medium">
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar is-large">
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar is-small is-rounded">
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar is-rounded">
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar is-medium is-rounded">
|
||||
<img src="http://www.gravatar.com/avatar" class="nes-avatar is-large is-rounded">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="form nes-container with-title">
|
||||
<h2 class="title">Form</h2>
|
||||
<div class="nes-field">
|
||||
|
@@ -7,3 +7,4 @@
|
||||
@import "balloons.scss";
|
||||
@import "tables.scss";
|
||||
@import "progress.scss";
|
||||
@import "avatar.scss";
|
||||
|
23
scss/elements/avatar.scss
Normal file
23
scss/elements/avatar.scss
Normal file
@@ -0,0 +1,23 @@
|
||||
@mixin img-style($param) {
|
||||
$size: $param * 16;
|
||||
|
||||
width: $size;
|
||||
height: $size;
|
||||
|
||||
&.is-rounded {
|
||||
border-radius: 50px;
|
||||
}
|
||||
}
|
||||
.nes-avatar {
|
||||
@include img-style(2px);
|
||||
|
||||
&.is-small {
|
||||
@include img-style(1px);
|
||||
}
|
||||
&.is-medium {
|
||||
@include img-style(3px);
|
||||
}
|
||||
&.is-large {
|
||||
@include img-style(4px);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user