Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                #app
  .title.pagetitle Boss Coding - IOS Calender
  .phone
    .calender(v-if="days.length>0")
      .head.flex.row
        .tag(v-for="tag in tags") {{tag}}
      .body.flex
        .daybox(v-for="(d,day_id) in days" ,:style="get_pan(d)" , :key="d",v-if="d",:class="{active: selected==day_id}" ,@click="selected=day_id")
          .infos
            .num {{d.number}}
            .lunar {{ lunar(d.lunar) }}
          .eventdot(:class="{has_event: d.events.length>0}")
      transition-group.todo_list(tag="div",name="fade",mode="out-in")
        .item(v-for="(todo,id) in current_items",:class="'type_'+todo.type",:key="todo",v-if="todo")
          .time {{todo.time}}
          .title {{todo.title}}
          .close_btn(@click="current_items.splice(id,1)") x
  .form
    input(name="title" v-model="newtodo.title" placeholder="標題")
    input(name="time"  v-model="newtodo.time" placeholder="時間")
    select(name="type" v-model="newtodo.type" placeholder="種類")
      option(value="work") 工作
      option(value="important") 重要
      option(value="school") 學校
      
    button(type="submit" @click="add_item") +
    
              
            
!

CSS

              
                @mixin size($w,$h: $w)
  width: $w
  height: $h

@mixin flex_center
  display: flex
  align-items: center
  justify-content: center
  flex-direction: column
  
*
  position: relative
  font-family: 'Roboto', '微軟正黑體'
  
html,body,#app
  +size(100%)
  background-color: #333
  +flex_center
  color: #555
  
.phone
  +size(360px,560px)
  background-color: #fff
  box-shadow: 0px 0px 10px rgba(black,0.6)
  overflow: hidden
  
.flex
  display: flex
  &.row
    flex-direction: row
    
.calender
  
  .head,.body
    border-bottom: solid 1px rgba(black,0.1)
    background-color: #f7f7f7
  .head
    padding-top: 50px
    padding-bottom: 5px
    .tag
      width: calc(100% / 7)
      text-align: center
      font-size: 12px
      
  .body
    flex-wrap: wrap
    padding-bottom: 10px
    .daybox
      box-sizing: border-box
      width: calc(100% / 7)
      text-align: center
      padding: 5px 0px
      cursor: pointer
      // border-radius: 50%
      // border: solid 1px 
      position: relative
      display: flex
      flex-direction: column
      align-items: center
      .infos
        display: flex
        flex-direction: column
        align-items: center
        // transition: 0.1s
      
      &.active
        color: white
        .infos
          background-color: #111
          
      .infos
        +size(40px)
        border-radius: 50%
      .num
        font-weight: 500
        font-size: 20px
        margin-top: 5px
      .lunar
        font-size: 12px
        margin-top: 1px
      .eventdot
        +size(6px)
        background-color: #ddd
        border-radius: 50%
        margin-top: 5px
        opacity: 0
        &.has_event
          opacity: 1
  .todo_list
    .item
      padding: 3px 10px
      display: flex
      height: 40px
      border-bottom: solid 1px rgba(0,0,0,0.1)
      transition: 0.5s
      
      &:hover
        background-color: #fafafa
        .close_btn
          opacity: 1
        
      .close_btn
        position: absolute
        top: 50%
        right: 20px
        transform: translateY(-50%)
        cursor: pointer
        opacity: 0
        transition: 0.5s
          
      .time,.title
        padding: 4px 10px
      .time
        width: 55px
        border-right: solid 2px
        border-color: #3ca9f2
      &.type_work
        .time
          border-color: #57ef34
      &.type_important
        .time
          border-color: #3ca9f2
      &.type_school
        .time
          border-color: #f9bf59
  
.form
  box-sizing: border-box
  padding: 10px
  position: absolute
  bottom: 0px
  width: 100%
  left: 0
  +flex_center
  flex-direction: row
  input,select
    box-sizing: border-box
    margin-right: 10px
    padding: 5px 10px
    border-radius: 2px
    min-width: 150px
    height: 30px
    color: white
    background-color: transparent
    border: none
    border: solid 1px white
  input[name='title']
    width: 300px
    
.pagetitle
  color: white
  font-size: 20px
  margin-bottom: 20px
    
.fade-enter-active,.fade-leave-active
  transition: 0.5s
.fade-enter,.fade-leave-to
  opacity: 0

  
              
            
!

JS

              
                var vm = new Vue({
  el: "#app",
  data: {
    tags: "日一二三四五六",
    days: [],
    start_day: 1,
    selected: 25,
    newtodo: {
      title: "",
      time: "",
      type: "important",
      
    }
  },
  mounted() {
    var lunar=6;
    for(var i=1;i<=31;i++){
      var new_day={
        number: i,
        lunar: lunar,
        events: []
      };
      if (Math.random()<0.4){
        var count=Math.random()*3;
        for(var o=0;o<count;o++){
          var minute=parseInt(Math.random()*3)*15;
          new_day.events.push(
            {title: ["整理房間丟垃圾","出門參加活動","打包行李"][parseInt(Math.random()*3)],
             place: "我的家裡",
             unique_id: Math.random()*100,
             time: parseInt(Math.random()*24)+":"+(minute==0?"0":"")+minute,
             type: ["work","important","school"][parseInt(Math.random()*3)],
           }
          );
        }
      }
      this.days.push(new_day);
      lunar++;
      // start_day++;
    }
  },
  methods:{
    chinese_num(num){
      var list="十一二三四五六七八九";
      return list[num];
    },
    lunar(num){
      if (num>30) num=num%30;
      if (num<11){
        return "初"+this.chinese_num(num%10) ;
      }else if (num<20){
        return "十"+this.chinese_num(num%10);
      }else if (num==20){
        return "二十";
      }else if (num<30){
        return "廿"+this.chinese_num(num%10);
      }else if (num<40){
        return "三"+this.chinese_num(num%10);
      }
    },
    get_pan(d){
      if (d.number==1){
        return { "margin-left": "calc( "+this.start_day+" * 100% / 7)"};
      }
    },
    add_item(){
      this.current_day.events.push(JSON.parse(JSON.stringify(this.newtodo )));
    }
  },computed: {
    current_day(){
      return this.days[this.selected];
    },
    current_items(){
      var day=this.current_day;
      if(!day)
        return null;
      else
        return day.events
            .sort((a,b)=>(parseInt(a.time.replace(":",""))-parseInt(b.time.replace(":","")) ));
    }
  }
});
              
            
!
999px

Console