用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/HKUDS/OpenSpace --skill react-localstorage-keyboard-nav命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification
Audio production with diagnostic analysis, timecode parsing from documents, and verified export workflow
Incremental audio production with duration alignment handling, per-stem verification, and adaptive extension strategies
基于 SOC 职业分类
| name | react-localstorage-keyboard-nav |
| description | Create React components with localStorage persistence and keyboard navigation support |
This skill guides you through creating reusable React components that:
// 1. Define localStorage hooks
const useLocalStorage = (key: string, initialValue: any) => {
const [value, setValue] = useState(() => {
const stored = localStorage.getItem(key);
return stored ? JSON.parse(stored) : initialValue;
});
useEffect(() => {
localStorage.setItem(key, JSON.stringify(value));
}, [key, value]);
return [value, setValue];
};
// 2. Implement keyboard navigation
const useKeyboardNav = (items: any[], onSelect: (item: any) => void) => {
const [selectedIndex, setSelectedIndex] = useState(0);
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'ArrowDown') {
setSelectedIndex(prev => Math.min(prev + 1, items.length - 1));
} else if (e.key === 'ArrowUp') {
setSelectedIndex(prev => Math.max(prev - 1, 0));
} else if (e.key === 'Enter') {
onSelect(items[selectedIndex]);
}
};
useEffect(() => {
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [selectedIndex, items]);
return { selectedIndex };
};
Create Component Scaffolding
mkdir -p src/components/{Modal,CommandPalette}
touch src/components/Modal/SettingsModal.tsx
touch src/components/CommandPalette/CommandPalette.tsx
Implement localStorage Persistence
// SettingsModal.tsx
const SettingsModal = () => {
const [settings, setSettings] = useLocalStorage('app-settings', DEFAULT_SETTINGS);
// ... modal implementation
};
Add Keyboard Navigation
// CommandPalette.tsx
const CommandPalette = ({ commands }) => {
const { selectedIndex } = useKeyboardNav(commands, (cmd) => cmd.action());
// ... render commands with highlighted selectedIndex
};
Export Components
// src/components/index.ts
export * from './Modal/SettingsModal';
export * from './CommandPalette/CommandPalette';
settings-keys.ts file to manage localStorage keys