Skip to content

Instantly share code, notes, and snippets.

@hidoos
Created February 25, 2014 02:36
Show Gist options
  • Save hidoos/9201592 to your computer and use it in GitHub Desktop.
Save hidoos/9201592 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.5)
// Compass (v1.0.0.alpha.18)
// ----
@charset "utf-8";
/**
* 对话框组件
* @file: 样式组件: _chat-content.sass
* @author: lanhong
* @update: 2013年12月20日11点
* @note: 聊天内容是一个组件,可以做成通用的
* @doc:
a. 访客是 visitor 客服是:worker
<ul class="msg-content>
<li class="msg-time" name="msg-time">
<span class="person visitor">访客名称</span>时间
</li>
<li class="msg-worker">
<p rel="chat-content" ng-bind-html="msg.msg">聊天的内容,你好,请问有什么可以帮您</p>
</li>
</ul>
*/
@mixin triangle ($size, $color, $direction) {
height: 0;
width: 0;
@if ($direction == up) or ($direction == down) or ($direction == right) or ($direction == left) {
border-color: transparent;
border-style: solid;
border-width: $size / 2;
@if $direction == up {
border-bottom-color: $color;
} @else if $direction == right {
border-left-color: $color;
} @else if $direction == down {
border-top-color: $color;
} @else if $direction == left {
border-right-color: $color;
}
}
@else if ($direction == up-right) or ($direction == up-left) {
border-top: $size solid $color;
@if $direction == up-right {
border-left: $size solid transparent;
} @else if $direction == up-left {
border-right: $size solid transparent;
}
}
@else if ($direction == down-right) or ($direction == down-left) {
border-bottom: $size solid $color;
@if $direction == down-right {
border-left: $size solid transparent;
} @else if $direction == down-left {
border-right: $size solid transparent;
}
}
}
$msgVisitorBorderColor:#d3e7fb;
$msgVisitorBgColor:#eef7fd;
$msgWorkerBorderColor:#d3e7fb;
$msgWorkerBgColor:#eef7fd;
$msgOtherBorderColor:$msgWorkerBorderColor;
$msgOtherBgColor:$msgWorkerBgColor;
$chatFontColor:#343434;
$fontSize:12px;
@mixin chatContentTriangle($person,$personBorderColor,$personBgColor){
position:relative;
border: 1px solid $personBorderColor;
border-radius: 4px;
// color: $workerFontColor !important;
background-color: $personBgColor;
@if ($person == visitor) or ($person == othor){
&:before{
@include triangle(12px,$personBgColor,up-left);
position:absolute;
z-index:23;
top:10px;
right:-10px;
}
&:after{
@include triangle(12px,$personBorderColor,up-left);
position:absolute;
z-index:22;
top:10px;
right:-11px;
}
}
@else if ($person == worker ){
&:before{
@include triangle(12px,$personBgColor,up-right);
position:absolute;
z-index:23;
top:10px;
right:-10px;
}
&:after{
@include triangle(12px,$personBorderColor,up-right);
position:absolute;
z-index:22;
top:10px;
right:-11px;
}
}
}
.msg-content {
margin-bottom: 10px;
color: #666666;
font-size: $fontSize;
line-height: 1.5;
// 设置聊天信息缩进 设置聊天信息为黑色
p[rel="chat-content"] {
padding: 7px 10px 10px 10px;
white-space: pre-wrap;
word-wrap: break-word;
word-break: break-all;
color: $chatFontColor;
a:hover {
text-decoration: underline;
}
}
// 聊天信息 : 设置聊天信息缩进,设置客服、访客名称的颜色
.person {
margin-right: 10px;
}
&.visitor {
//color: $visitorFontColor !important;
p[rel='chat-content']{
@include chatContentTriangle(visitor,$msgVisitorBorderColor,$msgVisitorBgColor);
}
}
&.worker {
p[rel='chat-content']{
@include chatContentTriangle(worker,$msgVisitorBorderColor,$msgVisitorBgColor);
}
}
&.other {
p[rel='chat-content']{
@include chatContentTriangle(other,$msgOtherBorderColor,$msgOtherBgColor);
}
}
}
@charset "UTF-8";
/**
* 对话框组件
* @file: 样式组件: _chat-content.sass
* @author: lanhong
* @update: 2013年12月20日11点
* @note: 聊天内容是一个组件,可以做成通用的
* @doc:
a. 访客是 visitor 客服是:worker
<ul class="msg-content>
<li class="msg-time" name="msg-time">
<span class="person visitor">访客名称</span>时间
</li>
<li class="msg-worker">
<p rel="chat-content" ng-bind-html="msg.msg">聊天的内容,你好,请问有什么可以帮您</p>
</li>
</ul>
*/
.msg-content {
margin-bottom: 10px;
color: #666666;
font-size: 12px;
line-height: 1.5;
}
.msg-content p[rel="chat-content"] {
padding: 7px 10px 10px 10px;
white-space: pre-wrap;
word-wrap: break-word;
word-break: break-all;
color: #343434;
}
.msg-content p[rel="chat-content"] a:hover {
text-decoration: underline;
}
.msg-content .person {
margin-right: 10px;
}
.msg-content.visitor p[rel='chat-content'] {
position: relative;
border: 1px solid #d3e7fb;
border-radius: 4px;
background-color: #eef7fd;
}
.msg-content.visitor p[rel='chat-content']:before {
height: 0;
width: 0;
border-top: 12px solid #eef7fd;
border-right: 12px solid transparent;
position: absolute;
z-index: 23;
top: 10px;
right: -10px;
}
.msg-content.visitor p[rel='chat-content']:after {
height: 0;
width: 0;
border-top: 12px solid #d3e7fb;
border-right: 12px solid transparent;
position: absolute;
z-index: 22;
top: 10px;
right: -11px;
}
.msg-content.worker p[rel='chat-content'] {
position: relative;
border: 1px solid #d3e7fb;
border-radius: 4px;
background-color: #eef7fd;
}
.msg-content.worker p[rel='chat-content']:before {
height: 0;
width: 0;
border-top: 12px solid #eef7fd;
border-left: 12px solid transparent;
position: absolute;
z-index: 23;
top: 10px;
right: -10px;
}
.msg-content.worker p[rel='chat-content']:after {
height: 0;
width: 0;
border-top: 12px solid #d3e7fb;
border-left: 12px solid transparent;
position: absolute;
z-index: 22;
top: 10px;
right: -11px;
}
.msg-content.other p[rel='chat-content'] {
position: relative;
border: 1px solid #d3e7fb;
border-radius: 4px;
background-color: #eef7fd;
}
@hidoos
Copy link
Author

hidoos commented Feb 25, 2014

使用sass编写的聊天冒泡框组件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment