Skip to content

Commit

Permalink
added list, listItems, outlined.scss directive, moved card texts to v…
Browse files Browse the repository at this point in the history
…ariables.scss
  • Loading branch information
DanielTerletzkiy committed Nov 21, 2021
1 parent 29b203b commit c1c659a
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 26 deletions.
55 changes: 43 additions & 12 deletions src/DEMO/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<div style="padding: 24px">
<d-card class="rounded-lg elevation">

<d-card-title class="font-size-large font-weight-light pa-0" color="primary">Hello, this is a test ;)</d-card-title>
<d-card-title class="font-size-large font-weight-light pa-0" color="primary">Hello, this is a test ;)
</d-card-title>

<d-checkbox class="pa-2 px-0" size="24" on-icon="sunset" off-icon="moonset" v-model="$store.state.theme.dark">
Darkmode
Expand All @@ -18,47 +19,63 @@
</d-card>

<div style="display: flex; gap: 8px; margin: 8px 0; flex-flow: row wrap;">
<d-btn color="success" filled>
<d-btn color="success" filled @click="changeColor('success')">
<d-icon name="check"/>
Success
</d-btn>
<d-btn color="error" filled>
<d-btn color="error" filled @click="changeColor('error')">
<d-icon name="exclamation-triangle"/>
Error
</d-btn>
<d-btn color="warning" filled>
<d-btn color="warning" filled @click="changeColor('warning')">
<d-icon name="exclamation-octagon"/>
Warning
</d-btn>
<d-btn color="info" filled>
<d-btn color="info" filled @click="changeColor('info')">
<d-icon name="info-circle"/>
Info
</d-btn>
</div>

<div style="display: flex; gap: 8px; margin: 8px 0; flex-flow: row wrap;">
<d-btn color="success" outlined depressed>
<d-btn color="success" outlined depressed @click="changeColor('success')">
<d-icon name="check"/>
Success
</d-btn>
<d-btn color="error" outlined>
<d-btn color="error" outlined @click="changeColor('error')">
<d-icon name="exclamation-triangle"/>
Error
</d-btn>
<d-btn color="warning">
<d-btn color="warning" @click="changeColor('warning')">
<d-icon name="exclamation-octagon"/>
Warning
</d-btn>
<d-btn color="info">
<d-btn color="info" @click="changeColor('info')">
<d-icon name="info-circle"/>
Info
</d-btn>
</div>

<d-btn color="primary" filled block @click="()=>this.$store.state.theme.themes.dark.primary = '#fafafa'">
<d-icon name="angle-left" size="32"/>This is full width <d-icon name="angle-right" size="32"/>
<d-btn color="primary" filled block @click="changeColor('primary')">
<d-icon name="angle-left" size="32"/>
This is full width
<d-icon name="angle-right" size="32"/>
</d-btn>
</d-card>

<div class="my-4"/>

<d-card class="elevation rounded-lg">
<d-card-title>
List with List items!
</d-card-title>
<d-list class="rounded-lg elevation-n2 ma-2" color="primary" v-model="listItem">
<d-list-item v-for="i in 21" :key="i-1">
<d-icon class="mr-1" :name="`${i-1}-plus`"/>
Item {{ i - 1 }}
</d-list-item>
</d-list>
</d-card>
</div>
</template>

Expand All @@ -68,17 +85,31 @@ import DCardTitle from "@/components/card/text/CardTitle";
import DBtn from "@/components/button/Button";
import DIcon from "@/components/icon/Icon";
import DCheckbox from "@/components/checkbox/Checkbox";
import DList from "@/components/list/List";
import DListItem from "@/components/list/ListItem";
export default {
name: 'HelloWorld',
components: {DCheckbox, DIcon, DBtn, DCard, DCardTitle},
components: {DListItem, DList, DCheckbox, DIcon, DBtn, DCard, DCardTitle},
props: {
msg: String
},
data: () => ({
listItem: 0
}),
methods: {
openGithub() {
window.open('https://github.com/DanielTerletzkiy/vue-materialize')
},
changeColor(color) {
if (this.$store.state.theme.dark) {
this.$store.state.theme.themes.dark.primary = this.processColor(color)
} else {
this.$store.state.theme.themes.light.primary = this.processColor(color)
}
}
}
}
Expand Down
12 changes: 1 addition & 11 deletions src/components/button/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
computed: {
classesObject() {
return {'d-btn--filled': this.filled, 'd-btn--outlined': this.outlined, 'd-btn--block': this.block, 'd-btn--depressed': this.depressed}
return {'d-btn--filled': this.filled, 'outlined': this.outlined, 'depressed': this.depressed, 'd-btn--block': this.block,}
},
}
}
Expand Down Expand Up @@ -113,16 +113,6 @@ export default {
justify-content: center;
gap: 4px
}
&.d-btn--outlined {
box-shadow: inset 0 0 0 1.4px currentColor;
&.d-btn--depressed.theme--dark {
box-shadow: inset 0 0 0 1.4px rgba(255, 255, 255, 0.12);
}
&.d-btn--depressed.theme--light {
box-shadow: inset 0 0 0 1.4px rgba(0, 0, 0, 0.12);
}
}
}
.theme--dark .d-btn {
Expand Down
4 changes: 2 additions & 2 deletions src/components/card/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export default {
.theme--dark {
.d-card {
background: $dark_sheet;
color: #bdbdbd;
color: $dark_card_text;
}
}
.theme--light {
.d-card {
background: $light_sheet;
color: #46474a;
color: $light_card_text;
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/components/list/List.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div class="d-list" :style="stylesObject" :class="themeClass">
<slot></slot>
</div>
</template>

<script>
export default {
name: "d-list",
props: {
value: Number
}
}
</script>

<style scoped lang="scss">
.d-list{
display: flex;
flex-direction: column;
padding: 8px;
}
</style>
94 changes: 94 additions & 0 deletions src/components/list/ListItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<template>
<div class="d-list__item" :class="Object.assign(classesObject ,themeClass)" :style="stylesObject" @click="click">
<div class="d-list__item__content">
<slot></slot>
</div>
</div>
</template>

<script>
export default {
name: "d-list-item",
computed: {
classesObject() {
return {'d-list__item--active /*outlined depressed*/': this.$parent.$props.value === this.$vnode.key}
}
},
methods: {
click() {
//check if listItem is under d-list
if (this.$parent._vnode.data.staticClass === 'd-list') {
this.$parent.$emit('input', this.$vnode.key)
} else {
this.$emit('input', this.$vnode.key)
}
}
}
}
</script>

<style scoped lang="scss">
@import "../../styles/variables";
.d-list__item {
position: relative;
border-radius: 8px;
min-height: 36px;
&::before {
position: absolute;
border-radius: inherit;
width: 100%;
height: 100%;
background: currentColor;
opacity: 0;
content: '';
transition-duration: 0.15s;
}
&:active {
&::before {
background-color: currentColor;
opacity: 0.2 !important;
}
}
&:hover {
&::before {
background: currentColor;
opacity: 0.1;
}
}
&:not(.d-list__item--active) {
&.theme--dark {
color: $dark_card_text
}
&.theme--light {
color: $light_card_text
}
}
&.d-list__item--active {
&::before {
background: currentColor;
opacity: 0.1;
}
}
.d-list__item__content {
padding: 8px;
display: flex;
align-items: center;
gap: $gap;
}
}
</style>
9 changes: 9 additions & 0 deletions src/styles/directives/outlined.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.outlined {
box-shadow: inset 0 0 0 1.4px currentColor;
&.depressed.theme--dark {
box-shadow: inset 0 0 0 1.4px rgba(255, 255, 255, 0.12);
}
&.depressed.theme--light {
box-shadow: inset 0 0 0 1.4px rgba(0, 0, 0, 0.12);
}
}
3 changes: 2 additions & 1 deletion src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@import "./directives/rounded";
@import "./directives/elevation";
@import "./directives/outlined";
@import "./directives/font";
@import "./directives/size";

body, html {
width: 100%;
height: 100%;
min-height: 100%;
margin: 0;
}

Expand Down
3 changes: 3 additions & 0 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
$dark_sheet: #242731;
$light_sheet: #ffff;

$dark_card_text: #bdbdbd;
$light_card_text: #46474a;

$gap: 4px;

0 comments on commit c1c659a

Please sign in to comment.