Skip to content

Instantly share code, notes, and snippets.

View shunwitter's full-sized avatar
🏄‍♂️

Shunsuke Sawada shunwitter

🏄‍♂️
View GitHub Profile
@shunwitter
shunwitter / KeyboardAvoidingView.jsx
Last active February 20, 2024 01:00
My KeyboardAvoidingView fixing annoying issues
/* eslint-disable */
import React, { useRef, useState, useEffect } from 'react'
import {
Keyboard, Dimensions, Animated
} from 'react-native'
const KeyboardSafeView = ({ children, style }) => {
const initialViewHeight = useRef(null)
const animatedViewHeight = useRef(null)
const [viewHeight, setViewHeight] = useState(null)
@shunwitter
shunwitter / KeyboardSafeView.jsx
Last active October 6, 2023 09:11
Temporary replacement with KeyboardAvoidingView
/* eslint-disable */
import React, { useRef, useState, useEffect } from 'react'
import {
Keyboard, Dimensions, Animated
} from 'react-native'
const KeyboardSafeView = ({ children, style }) => {
const initialViewHeight = useRef(null)
const animatedViewHeight = useRef(null)
const [viewHeight, setViewHeight] = useState(null)
@shunwitter
shunwitter / routes.rb
Created October 25, 2016 01:09
Vuejs Simple Convention
Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
post 'my_component_data_a'
post 'my_component_data_b'
end
end
@shunwitter
shunwitter / my_api_controller.rb
Last active October 25, 2016 01:11
Vuejs Simple Convention
# /api/my_api_controller.rb
class Api::MyApiController < Api::BaseController
def my_component_a_data
# Fetch data from rails and return json
@my_data_a = { title: 'Hello world', body: 'Vue.js is simple and easy to use.' }
render json: @my_data_a
end
def my_component_b_data
@shunwitter
shunwitter / entry.js
Created October 25, 2016 01:01
Vuejs Simple Convention
const Vue = require('vue')
const App = require('./components/App.vue')
// Convention: Global object for events
window.eventHub = new Vue()
new Vue({
el: '#my-app',
components: {
app: App,
@shunwitter
shunwitter / MyComponentA.vue
Created October 25, 2016 00:59
Vuejs Simple Convention
<template lang="pug">
h1 {{title}}
p {{body}}
</template>
<script>
export default {
// Convention: Component name is camel case
name: 'MyComponentA',
props: {},
@shunwitter
shunwitter / App.vue
Last active October 25, 2016 01:13
Vuejs Simple Convention
<template lang="pug">
#my-app
.container
my-component-a
my-component-b
</template>
<style lang="sass?indentedSyntax" scoped>
.container
width: 800px //whatever