Преглед изворни кода

lesson 11: Exercise 3: Bulma tabs, avoiding props mutations.

Frederic G. MARAND пре 7 година
родитељ
комит
410083bbed
4 измењених фајлова са 250 додато и 23 уклоњено
  1. 124 23
      .idea/workspace.xml
  2. 69 0
      lesson11/code.js
  3. 38 0
      lesson11/index.html
  4. 19 0
      lesson11/styles.css

+ 124 - 23
.idea/workspace.xml

@@ -5,7 +5,6 @@
       <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lesson11/code.js" />
       <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lesson11/index.html" />
       <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lesson11/styles.css" />
-      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lesson10/index.html" afterPath="$PROJECT_DIR$/lesson10/index.html" />
     </list>
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
     <option name="TRACKING_ENABLED" value="true" />
@@ -61,8 +60,10 @@
         <option value="$PROJECT_DIR$/lesson08/index.html" />
         <option value="$PROJECT_DIR$/lesson09/index.html" />
         <option value="$PROJECT_DIR$/lesson10/code.js" />
-        <option value="$PROJECT_DIR$/lesson11/index.html" />
         <option value="$PROJECT_DIR$/lesson10/index.html" />
+        <option value="$PROJECT_DIR$/lesson11/styles.css" />
+        <option value="$PROJECT_DIR$/lesson11/index.html" />
+        <option value="$PROJECT_DIR$/lesson11/code.js" />
       </list>
     </option>
   </component>
@@ -123,27 +124,13 @@
               <option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
             </PATH_ELEMENT>
           </PATH>
-          <PATH>
-            <PATH_ELEMENT>
-              <option name="myItemId" value="laracasts" />
-              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
-            </PATH_ELEMENT>
-            <PATH_ELEMENT>
-              <option name="myItemId" value="laracasts" />
-              <option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
-            </PATH_ELEMENT>
-            <PATH_ELEMENT>
-              <option name="myItemId" value="lesson10" />
-              <option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
-            </PATH_ELEMENT>
-          </PATH>
         </subPane>
       </pane>
       <pane id="Scope" />
     </panes>
   </component>
   <component name="PropertiesComponent">
-    <property name="settings.editor.selected.configurable" value="reference.webide.settings.project.settings.php" />
+    <property name="settings.editor.selected.configurable" value="preferences.keymap" />
     <property name="js.eslint.nodeInterpreter" value="/usr/local/bin/node" />
     <property name="js.eslint.eslintPackage" value="/usr/local/lib/node_modules/eslint" />
     <property name="last_opened_file_path" value="$PROJECT_DIR$/../../../go/src/github.com" />
@@ -174,6 +161,106 @@
       </list>
     </option>
   </component>
+  <component name="RunManager">
+    <configuration default="true" type="BashConfigurationType" factoryName="Bash">
+      <option name="INTERPRETER_OPTIONS" value="" />
+      <option name="INTERPRETER_PATH" value="/bin/bash" />
+      <option name="WORKING_DIRECTORY" value="" />
+      <option name="PARENT_ENVS" value="true" />
+      <option name="SCRIPT_NAME" value="" />
+      <option name="PARAMETERS" value="" />
+      <module name="" />
+      <envs />
+      <method />
+    </configuration>
+    <configuration default="true" type="CodeceptionConfigurationType" factoryName="Codeception">
+      <PhpTestRunnerSettings />
+      <method />
+    </configuration>
+    <configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
+      <module name="" />
+      <working_directory value="$PROJECT_DIR$" />
+      <filePath value="$PROJECT_DIR$" />
+      <kind value="FILE" />
+      <method />
+    </configuration>
+    <configuration default="true" type="GoRunFileConfiguration" factoryName="Go Single File">
+      <module name="" />
+      <working_directory value="$PROJECT_DIR$" />
+      <filePath value="$PROJECT_DIR$" />
+      <method />
+    </configuration>
+    <configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
+      <module name="" />
+      <working_directory value="$PROJECT_DIR$" />
+      <framework value="gotest" />
+      <kind value="DIRECTORY" />
+      <method />
+    </configuration>
+    <configuration default="true" type="JavaScriptTestRunnerJest" factoryName="Jest">
+      <node-interpreter value="project" />
+      <working-dir value="" />
+      <envs />
+      <scope-kind value="ALL" />
+      <method />
+    </configuration>
+    <configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma">
+      <config-file value="" />
+      <node-interpreter value="project" />
+      <envs />
+      <method />
+    </configuration>
+    <configuration default="true" type="JavaScriptTestRunnerProtractor" factoryName="Protractor">
+      <config-file value="" />
+      <node-interpreter value="project" />
+      <envs />
+      <method />
+    </configuration>
+    <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
+      <method />
+    </configuration>
+    <configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="project" working-dir="">
+      <method />
+    </configuration>
+    <configuration default="true" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
+      <TestRunner />
+      <method />
+    </configuration>
+    <configuration default="true" type="PhpBehatConfigurationType" factoryName="Behat">
+      <BehatRunner />
+      <method />
+    </configuration>
+    <configuration default="true" type="PhpLocalRunConfigurationType" factoryName="PHP Console">
+      <method />
+    </configuration>
+    <configuration default="true" type="PhpSpecConfigurationType" factoryName="PHPSpec">
+      <PhpTestRunnerSettings />
+      <method />
+    </configuration>
+    <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
+      <method />
+    </configuration>
+    <configuration default="true" type="js.build_tools.npm" factoryName="npm">
+      <command value="run" />
+      <scripts />
+      <node-interpreter value="project" />
+      <envs />
+      <method />
+    </configuration>
+    <configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
+      <node-interpreter>project</node-interpreter>
+      <node-options />
+      <working-directory />
+      <pass-parent-env>true</pass-parent-env>
+      <envs />
+      <ui />
+      <extra-mocha-options />
+      <test-kind>DIRECTORY</test-kind>
+      <test-directory />
+      <recursive>false</recursive>
+      <method />
+    </configuration>
+  </component>
   <component name="ShelveChangesManager" show_recycled="false">
     <option name="remove_strategy" value="false" />
   </component>
@@ -189,7 +276,7 @@
     <servers />
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="7417000" />
+    <option name="totallyTimeSpent" value="9756000" />
   </component>
   <component name="ToolWindowManager">
     <frame x="0" y="23" width="1440" height="877" extended-state="6" />
@@ -556,18 +643,32 @@
         </state>
       </provider>
     </entry>
-    <entry file="file://$PROJECT_DIR$/lesson11/index.html">
+    <entry file="file://$PROJECT_DIR$/lesson11/styles.css">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="225">
-          <caret line="14" column="32" lean-forward="false" selection-start-line="14" selection-start-column="32" selection-end-line="14" selection-end-column="32" />
+        <state relative-caret-position="285">
+          <caret line="19" column="0" lean-forward="true" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
           <folding />
         </state>
       </provider>
     </entry>
     <entry file="file://$PROJECT_DIR$/lesson11/code.js">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="165">
-          <caret line="11" column="4" lean-forward="true" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" />
+        <state relative-caret-position="700">
+          <caret line="69" column="0" lean-forward="true" selection-start-line="69" selection-start-column="0" selection-end-line="69" selection-end-column="0" />
+          <folding>
+            <marker date="1496683765000" expanded="true" signature="42:310" ph="..." />
+            <marker date="1496683765000" expanded="true" signature="63:242" ph="..." />
+            <marker date="1496683765000" expanded="true" signature="72:233" ph="..." />
+            <marker date="1496683765000" expanded="true" signature="142:225" ph="..." />
+            <marker date="1496683765000" expanded="true" signature="276:303" ph="..." />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/lesson11/index.html">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="585">
+          <caret line="38" column="0" lean-forward="true" selection-start-line="38" selection-start-column="0" selection-end-line="38" selection-end-column="0" />
           <folding />
         </state>
       </provider>

+ 69 - 0
lesson11/code.js

@@ -0,0 +1,69 @@
+Vue.component('tabs', {
+  template: `
+<div>
+  <div class="tabs">
+    <ul>
+      <li v-for="tab in tabs" :class="{ 'is-active': tab.isActive }">
+        <a :href="tab.href" @click="selectTab(tab)">{{ tab.name }}</a>
+      </li>
+  </ul>
+  </div>
+    
+  <div class="tabs-details">
+    <slot></slot>
+  </div>
+</div>
+`,
+
+  created() {
+    this.tabs = this.$children;
+  },
+
+  data() {
+    return {
+      tabs: [],
+    };
+  },
+
+  methods: {
+    selectTab(selectedTab) {
+      this.tabs.forEach(tab => {
+        tab.isActive = (tab.name === selectedTab.name);
+      });
+    }
+  },
+});
+
+Vue.component('tab', {
+  computed: {
+    href() {
+      return '#' + this.name.toLowerCase().replace(/ /g, '-');
+    }
+  },
+
+  data() {
+    return {
+      isActive: false
+    };
+  },
+
+  mounted() {
+    this.isActive = this.selected;
+  },
+
+  props: {
+    name: { required: true },
+    selected: { default: false },
+  },
+
+  template: `
+<div v-show="isActive"><slot></slot></div>
+`,
+
+});
+
+const app = new Vue({
+  el: '#root',
+  data: {
+  },
+});

+ 38 - 0
lesson11/index.html

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.2.3/css/bulma.css" />
+    <link rel="stylesheet" href="../styles.css" />
+    <link rel="stylesheet" href="styles.css" />
+  </head>
+  <body>
+    <nav>
+      <h1><span class="index">11</span>Exercise 3: Bulma tabs</h1>
+      <ul>
+        <li><a href="../lesson10">Prev</a></li>
+        <li><a href="../lesson12">Next</a></li>
+      </ul>
+    </nav>
+
+    <div id="root" class="container">
+      <tabs>
+        <tab name="About us" :selected="true">
+          <h1>Here is the content about us</h1>
+        </tab>
+
+        <tab name="About our culture">
+          <h1>Here is the content about our culture</h1>
+        </tab>
+
+        <tab name="About our vision">
+          <h1>Here is the content about our vision</h1>
+        </tab>
+      </tabs>
+    </div>
+
+    <script src="../lib/vue-2.1.3.js"></script>
+    <script src="code.js"></script>
+  </body>
+</html>

+ 19 - 0
lesson11/styles.css

@@ -0,0 +1,19 @@
+body {
+  padding-top: 40px;
+}
+
+nav li {
+  display: inline;
+}
+
+nav h1 span {
+  margin-right: 0.3em;
+}
+
+button {
+  display: block;
+}
+
+[v-cloak] {
+  display: none;
+}