-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Accordion #20
Merged
HarshCasper
merged 7 commits into
moja-global:main
from
Palaksharma23:componentaccordion
Jul 25, 2022
Merged
Added Accordion #20
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2bd1bcc
Added Accordion
Palaksharma23 f06e7a2
merge main
Palaksharma23 4383939
Changed props to camelCase
Palaksharma23 e3d83b2
Merge branch 'main' into componentaccordion
Palaksharma23 16016d9
resolved errors
Palaksharma23 0444047
changed color of primary dark content
Palaksharma23 93f6bdb
fixed error
Palaksharma23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<template> | ||
<div :class="[centerItem ? 'center' : ' ', 'container']"> | ||
<slot></slot> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "AccordionComponent", | ||
props: { | ||
width: { | ||
type: String, | ||
default: "80vw", | ||
}, | ||
centerItem: { | ||
type: Boolean, | ||
default: "true", | ||
}, | ||
}, | ||
setup() {}, | ||
}; | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style scoped> | ||
.center { | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
.container { | ||
width: v-bind(width); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<template> | ||
<div :class="[toggle ? isActive : '']" @click="accordionhandler($event)"> | ||
<div :class="[label, 'label_box']">{{ heading }}</div> | ||
<div :class="content" class="content"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ref } from "vue"; | ||
export default { | ||
name: "AccordionItem", | ||
props: { | ||
heading: String, | ||
label: String, | ||
content: String, | ||
fsContent: { | ||
type: String, | ||
default: "1.4vw", | ||
}, | ||
fsHeading: { | ||
type: String, | ||
default: "2vw", | ||
}, | ||
bgHeading: { | ||
type: String, | ||
default: "#2e382b", | ||
}, | ||
headingColor: { | ||
type: String, | ||
default: "#ffffff", | ||
}, | ||
bgContent: { | ||
type: String, | ||
default: "#475447", | ||
}, | ||
contentColor: { | ||
type: String, | ||
default: "#f7f5f7", | ||
}, | ||
borderColor: { | ||
type: String, | ||
default: "#475447", | ||
}, | ||
}, | ||
setup() { | ||
const toggle = ref(false); | ||
const isActive = ref("active"); | ||
|
||
function accordionhandler(e) { | ||
toggle.value = !toggle.value; | ||
e.preventDefault(); | ||
let content = e.target.nextElementSibling; | ||
if (!toggle.value) { | ||
content.style.maxHeight = null; | ||
} else { | ||
content.style.maxHeight = content.scrollHeight + "px"; | ||
} | ||
} | ||
|
||
return { | ||
toggle, | ||
accordionhandler, | ||
isActive, | ||
}; | ||
}, | ||
}; | ||
</script> | ||
|
||
<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
<style scoped> | ||
.label_secondary { | ||
font-size: v-bind(fsHeading); | ||
font-family: sans-serif; | ||
background-color: v-bind(bgHeading); | ||
padding: 1%; | ||
padding-left: 2%; | ||
color: v-bind(headingColor); | ||
border: 1px solid v-bind(borderColor); | ||
} | ||
|
||
.content_secondary, | ||
.content_secondary_dark { | ||
background-color: v-bind(bgContent); | ||
} | ||
|
||
.content_secondary_dark { | ||
color: v-bind(contentColor); | ||
} | ||
|
||
.label_secondary::before { | ||
content: "+"; | ||
float: right; | ||
color: v-bind(headingColor); | ||
padding-right: 1%; | ||
} | ||
|
||
.active .label_secondary::before { | ||
content: "-"; | ||
} | ||
|
||
.active .content_secondary, | ||
.active .content_secondary_dark { | ||
background-color: v-bind(bgContent); | ||
} | ||
|
||
.active .content_secondary_dark { | ||
color: v-bind(contentColor); | ||
} | ||
|
||
.label_primary, | ||
.label_primary_dark { | ||
font-size: v-bind(fsHeading); | ||
font-family: sans-serif; | ||
|
||
background-color: v-bind(bgHeading); | ||
padding: 1%; | ||
color: v-bind(headingColor); | ||
border-bottom: 1px solid v-bind(borderColor); | ||
} | ||
|
||
.content_primary { | ||
background-color: v-bind(bgContent); | ||
} | ||
|
||
.content_primary_dark { | ||
background-color: v-bind(bgHeading); | ||
color: v-bind(contentColor); | ||
} | ||
|
||
.label_primary::before, | ||
.label_primary_dark::before { | ||
content: "+"; | ||
float: left; | ||
border-radius: 50%; | ||
margin-right: 2%; | ||
width: 10px; | ||
} | ||
|
||
.active .label_primary::before, | ||
.active .label_primary_dark::before { | ||
content: "-"; | ||
} | ||
|
||
.active .content_primary { | ||
background-color: v-bind(bgContent); | ||
} | ||
|
||
.active .content_primary_dark { | ||
background-color: v-bind(bgHeading); | ||
color: v-bind(contentColor); | ||
} | ||
|
||
.content { | ||
padding: 0 18px; | ||
max-height: 0; | ||
overflow: hidden; | ||
transition: max-height 0.4s ease-out; | ||
font-size: v-bind(fsContent); | ||
font-family: sans-serif; | ||
} | ||
|
||
.label_box { | ||
cursor: pointer; | ||
} | ||
</style> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either give the name of variables in camelCase or PascalCase or snake_case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's go with camelCase